예제 #1
0
void QosProcessorThreaded::setUp() 
{

	try
	{
		string commandLine = "qualityManager";
		char *cstr = new char[commandLine.length() + 1];
		strcpy(cstr, commandLine.c_str());
		
		enum { kMaxArgs = 64 };
		int argc = 0;
		char *argv[kMaxArgs];

		char *p2 = strtok(cstr, " ");
		while (p2 && argc < kMaxArgs-1)
		{
			argv[argc++] = p2;
			p2 = strtok(0, " ");
		}
		argv[argc] = 0;
					
		const string configDTD = DEF_SYSCONFDIR "/netqos_conf.dtd";
		const string configFileName = NETQOS_DEFAULT_CONFIG_FILE;
		conf = new ConfigManager(configDTD, configFileName, argv[0]);

        log = Logger::getInstance(); 	
        ch = log->createChannel("QoSProcessor_test");

        // set logging vebosity level if configured
        string verbosity = conf->getValue("VerboseLevel", "MAIN");
        if (!verbosity.empty()) {
            log->setLogLevel( ParserFcts::parseInt( verbosity, -1, 4 ) );
        }
				
		qosProcessorPtr = new QOSProcessor( conf , 1);
        
        rulem =  new RuleManager(conf->getValue("FilterDefFile", "MAIN"), 
                            conf->getValue("FilterConstFile", "MAIN"));
  
        evnt = new EventScheduler();
		
        qosProcessorPtr->run();
        		        
	}
	catch(Error &e){
		cout << "Error:" << e.getError() << endl << flush;
		throw e;
	}
		
}
예제 #2
0
JNIEXPORT jint JNICALL Java_us_ihmc_aci_dspro2_DSProLauncher_startNative (JNIEnv *pEnv, jobject joThis)
{
    DSPro *pDSPro = checkAndRetrieveDSProPtr (pEnv, joThis);
    if (pDSPro == NULL) {
        return -1;
    }

    ConfigManager *pCfgMgr = checkAndRetrieveCfgMgrPtr (pEnv, joThis);
    if (pCfgMgr == NULL) {
        return -2;
    }

    DSProProxyServer proxySrv;
    const char *pszProxyServerInterface = NULL;
    uint16 ui16ProxyServerPort = 56487; // DISPRO_SVC_PROXY_SERVER_PORT_NUMBER;
    if (pCfgMgr->hasValue ("aci.disservice.proxy.interface")) {
        pszProxyServerInterface = pCfgMgr->getValue ("aci.disservice.proxy.interface");
    }
    if (pCfgMgr->hasValue ("aci.disservice.proxy.port")) {
        ui16ProxyServerPort = (uint16) pCfgMgr->getValueAsInt ("aci.disservice.proxy.port", 56487);
    }

    if (proxySrv.init (pDSPro, pszProxyServerInterface, ui16ProxyServerPort) != 0) {
        if (pLogger != NULL) {
            pLogger->logMsg ("main", Logger::L_SevereError,
                "DSProProxyServer has failed to initialize\n");
        }
        return -3;
    }
    proxySrv.start();

    return 0;
}
예제 #3
0
JNIEXPORT jstring JNICALL Java_us_ihmc_aci_dspro2_DSProLauncher_getNodeId (JNIEnv *pEnv, jobject joThis)
{
	ConfigManager *pCfgMgr = checkAndRetrieveCfgMgrPtr (pEnv, joThis);
	if (pCfgMgr == NULL) {
		return NULL;
	}

	String nodeId;
	if (pCfgMgr->hasValue ("aci.dspro.node.id")) {
		nodeId = pCfgMgr->getValue ("aci.dspro.node.id");
	}
	else if (pCfgMgr->hasValue ("aci.disService.nodeUUID")) {
		// for backward compatibility
		nodeId = pCfgMgr->getValue ("aci.disService.nodeUUID");
	}
	else if (pCfgMgr->hasValue ("aci.dspro.node.id.auto") &&
		(strcmp ("hostname", pCfgMgr->getValue ("aci.dspro.node.id.auto")) == 0)) {
		nodeId = NetUtils::getLocalHostName();
		pCfgMgr->setValue ("aci.dspro.node.id", nodeId);
	}
	else if (pCfgMgr->hasValue ("aci.disService.nodeUUID.auto.mode") &&
		(strcmp ("hostname", pCfgMgr->getValue ("aci.disService.nodeUUID.auto.mode")) == 0)) {
		// for backward compatibility
		nodeId = NetUtils::getLocalHostName();
		pCfgMgr->setValue ("aci.dspro.node.id", nodeId);
	}
	else {
		NOMADSUtil::UUID uuid;
		uuid.generate();
		const char *pszUUID = uuid.getAsString();
		if (pszUUID != NULL) {
			nodeId = pszUUID;
		}
	}

	if (nodeId == NULL) {
		return NULL;
	}

	return pEnv->NewStringUTF (nodeId.c_str());
}
예제 #4
0
void AdvectionManager::init(const Domain &domain, const Mesh &mesh,
                            const ConfigManager &configManager,
                            const TimeManager &timeManager) {
    this->domain = &domain;
    this->mesh = &mesh;

    io.init(timeManager);
    string output_prefix;
    if (configManager.hasKey("tspas", "output_prefix")) {
        configManager.getValue("tspas", "output_prefix", output_prefix);
    } else {
        output_prefix = "tspas."+
            boost::lexical_cast<string>(mesh.getNumGrid(0, FULL))+"x"+
            boost::lexical_cast<string>(mesh.getNumGrid(1, FULL));
    }
    outputFileIdx = io.registerOutputFile(mesh, output_prefix,
                                          IOFrequencyUnit::STEPS, 10);

    Qstar.create("qstar", "N/A", "intermediate tracer density", mesh, CENTER);
    FX.create("fx", "N/A", "flux along x direction", mesh, X_FACE);
    FY.create("fy", "N/A", "flux along y direction", mesh, Y_FACE);
    A.create("a", "N/A", "shape-preserving judger", mesh, CENTER);
    B.create("b", "N/A", "beta", mesh, CENTER);
    volume.create("volume", "m2 or m3", "the volume of grid cells", mesh, CENTER);
    
    io.file(outputFileIdx).registerOutputField<double, 1, FULL_DIMENSION>(1, &volume);

    int js = 0, jn = mesh.getNumGrid(1, FULL)-1;

    for (int i = 0; i < mesh.getTotalNumGrid(CENTER); ++i) {
        volume(i) = mesh.getCellVolume(i);
    }

    dlon.resize(mesh.getNumGrid(0, HALF));
    for (int i = 0; i < mesh.getNumGrid(0, HALF); ++i) {
        dlon[i] = mesh.getGridInterval(0, FULL, i); // this is correct
    }
    dlat.resize(mesh.getNumGrid(1, HALF));
    for (int j = 0; j < mesh.getNumGrid(1, HALF); ++j) {
        dlat[j] = mesh.getGridInterval(1, FULL, j); // this is correct
    }
    cosLatFull.set_size(mesh.getNumGrid(1, FULL));
    for (int j = 0; j < mesh.getNumGrid(1, FULL); ++j) {
        cosLatFull[j] = mesh.getCosLat(FULL, j);
    }
    cosLatFull[js] = 0;
    cosLatFull[jn] = 0;
    cosLatHalf.set_size(mesh.getNumGrid(1, HALF));
    for (int j = 0; j < mesh.getNumGrid(1, HALF); ++j) {
        cosLatHalf[j] = mesh.getCosLat(HALF, j);
    }
}
예제 #5
0
int DSProUtils::addPeers (DSPro &dspro, ConfigManager &cfgMgr)
{
    const char *pszMethodName = "DSProUtils::addPeers";
    const uint16 ui16MocketsPort = static_cast<uint16>(cfgMgr.getValueAsInt ("aci.dspro.adaptor.mockets.port", MocketsAdaptor::DEFAULT_PORT));
    StringHashset mocketsAddresses;
    parsePeers (cfgMgr.getValue ("aci.dspro.adaptor.mockets.peer.addr"), mocketsAddresses);
    const int mocketsRc = addPeer (dspro, MOCKETS, mocketsAddresses, ui16MocketsPort);

    const uint16 ui16TCPPort = static_cast<uint16>(cfgMgr.getValueAsInt ("aci.dspro.adaptor.tcp.port", TCPAdaptor::DEFAULT_PORT));
    StringHashset tcpAddresses;
    parsePeers (cfgMgr.getValue ("aci.dspro.adaptor.tcp.peer.addr"), tcpAddresses);
    const int iCount = tcpAddresses.getCount();
    tcpAddresses.removeAll (mocketsAddresses);
    if (iCount > tcpAddresses.getCount()) {
        checkAndLogMsg (pszMethodName, Logger::L_Warning,
                        "trying to connect to the same peer with both Mockets and TCP. "
                        "The duplicated connections via TCP will be dropped.\n");
    }
    const int tcpRc = addPeer (dspro, TCP, tcpAddresses, ui16TCPPort);

    return (mocketsRc + tcpRc);
}
예제 #6
0
int main (int argc, char *argv[])
{
    _m.lock();
    _terminated = false;
    _m.unlock();

    if (signal (SIGINT, sigIntHandler) == SIG_ERR) {
        printf ("Error handling SIGINT\n");
        exit (-1);
    }

    ConfigManager *pConfigManager = NULL;
    uint16 ui16Port = DIS_SVC_PROXY_SERVER_PORT_NUMBER;

    // Read Configuration
    if (argc > 2) {
        printf ("Usage: ./DisServiceProxy <configFile>\n");
        exit (-2);
    }

    if (argv[1]) {
        if (FileUtils::fileExists(argv[1])) {
            pConfigManager = new ConfigManager();
            pConfigManager->init();
            int rc;
            if ((rc = pConfigManager->readConfigFile((const char *) argv[1])) != 0) {
                printf ("Error in config file %s reading. Returned code %d.\n", (const char *) argv[1], rc);
                exit (-3);
            }
            if (pConfigManager->hasValue("aci.disservice.proxy.port")) {
                ui16Port = (uint16) pConfigManager->getValueAsInt("aci.disservice.proxy.port");
            }
            if (pConfigManager->getValueAsBool("util.logger.enabled", true)) {
                if (!pLogger) {
                    pLogger = new Logger();
                    if (pConfigManager->getValueAsBool("util.logger.out.screen.enabled", true)) {
                        pLogger->enableScreenOutput();
                    }
                    if (pConfigManager->getValueAsBool("util.logger.out.file.enabled", true)) {
                        pLogger->initLogFile (pConfigManager->getValue ("util.logger.out.file.path", "ds.log"), false);
                        pLogger->enableFileOutput();
                        pLogger->initErrorLogFile (pConfigManager->getValue ("util.logger.error.file.path", "dserror.log"), false);
                        pLogger->enableErrorLogFileOutput();
                    }
                    uint8 ui8DbgDetLevel = (uint8) pConfigManager->getValueAsInt ("util.logger.detail", Logger::L_LowDetailDebug);
                    switch (ui8DbgDetLevel) {
                        case Logger::L_SevereError:
                        case Logger::L_MildError:
                        case Logger::L_Warning:
                        case Logger::L_Info:
                        case Logger::L_NetDetailDebug:
                        case Logger::L_LowDetailDebug:
                        case Logger::L_MediumDetailDebug:
                        case Logger::L_HighDetailDebug:
                            pLogger->setDebugLevel (ui8DbgDetLevel);
                            pLogger->logMsg ("DisServiceLauncher::main", Logger::L_Info,
                                             "Setting debug level to %d\n", ui8DbgDetLevel);
                            break;
                        default:
                            pLogger->setDebugLevel(Logger::L_LowDetailDebug);
                            pLogger->logMsg("DisServiceLauncher::main",
                                            Logger::L_Info,
                                            "Invalid Logger detail debug level. Setting it to %d\n",
                                            Logger::L_LowDetailDebug);
                    }
                }
            }
        }
        else {
            printf ("The file at location: %s does not exist.\n", (const char *) argv[1]);
            exit (-4);
        }
    }

    if (pConfigManager == NULL) {
        // Default Logger conf
        if (!pLogger) {
            pLogger = new Logger();
            pLogger->enableScreenOutput();
            pLogger->initLogFile("disseminationservice.log",false);
            pLogger->enableFileOutput();
            pLogger->setDebugLevel(Logger::L_LowDetailDebug);
        }
    }

    if (pLogger != NULL) {
        pLogger->displayAbsoluteTime();
    }

    //Initializing and starting DisService
    DisseminationService * _pDisService = (pConfigManager ? new DisseminationService(pConfigManager) : new DisseminationService());
    int rc;
    if (0 != (rc = _pDisService->init())) {
    	printf ("\nDisseminationService is failed to initialize\n");
        return -5;
    }
    _pDisService->start();

    // Initializing and starting ProxyServer
    DisseminationServiceProxyServer dsProxyServer;

    dsProxyServer.init (_pDisService, ui16Port);
    dsProxyServer.start();
    printf ("\nDisseminationProxyServer is running on port %d\n", ui16Port);

    // Invoking the command processor
    pLogger->disableScreenOutput();
    DisServiceCommandProcessor cmdProc (_pDisService);
    cmdProc.setPrompt ("DisService");
    cmdProc.enableNetworkAccess (5555);
    cmdProc.run();

    printf ("\nDisService is terminating...\n");
    _pDisService->requestTerminationAndWait();
    delete _pDisService;
    _pDisService = NULL;
    delete pLogger;
    pLogger = NULL;
    delete pConfigManager;
    pConfigManager = NULL;

    return 0;
}
예제 #7
0
파일: main.cpp 프로젝트: fanghuan/IAP-CGFD
int main(int argc, const char *argv[])
{
    ConfigManager configManager;
    Domain domain(1);
    Mesh mesh(domain, 2);
    Field<double, 2> u, f;
    Field<double> fu;
    TimeManager timeManager;
    IOManager io;
    int outputFileIdx;
    TimeLevelIndex<2> oldIdx, newIdx, halfIdx;

    double dt, dx;
    string outputPattern = "beam_warming.%3s.nc";

    if (argc != 2) {
        REPORT_ERROR("Configure file is needed!");
    }

    // Read configuration from file.
    configManager.parse(argv[1]);
    dt = configManager.getValue("beam_warming", "dt", 1);
    dx = configManager.getValue("beam_warming", "dx", 0.01);
    outputPattern = configManager.getValue("beam_warming", "output_pattern", outputPattern);

    // Set the one dimensional space axis.
    domain.setAxis(0, "x", "x axis", "m",
                   0, geomtk::BndType::PERIODIC,
                   1, geomtk::BndType::PERIODIC);

    // Set the discrete mesh on the domain.
    mesh.init(domain.axisSpan(0)/dx);

    // Set the time manager.
    Time startTime(0*geomtk::TimeUnit::SECONDS);
    Time endTime(200*geomtk::TimeUnit::SECONDS);
    timeManager.init(startTime, endTime, dt);

    // Set up velocity and density fields.
    u.create("u", "m s-1", "velocity component along x axis", mesh, X_FACE, 1, true);
    f.create("f", "kg m-1", "tracer density", mesh, CENTER, 1);
    fu.create("fu", "kg s-1", "tracer mass flux", mesh, X_FACE, 1);

    // Set the initial conditions.
    newIdx = oldIdx+1;
    for (int i = mesh.is(HALF); i <= mesh.ie(HALF); ++i) {
        u(oldIdx, i) = 0.005;
        u(newIdx, i) = 0.005;
    }
    u.applyBndCond(oldIdx);
    u.applyBndCond(newIdx, true);
    for (int i = mesh.is(FULL); i <= mesh.ie(FULL); ++i) {
        const SpaceCoord &x = mesh.gridCoord(CENTER, i);
        if (x(0) >= 0.05 && x(0) <= 0.1) {
            f(oldIdx, i) = 1.0;
        } else {
            f(oldIdx, i) = 0.0;
        }
    }
    f.applyBndCond(oldIdx);

    // Set up IO manager.
    io.init(timeManager);
    outputFileIdx = io.registerOutputFile(mesh, outputPattern, geomtk::TimeStepUnit::STEP, 1);
    io.registerField(outputFileIdx, "double", FULL_DIMENSION, {&f});
    io.output<double, 2>(outputFileIdx, oldIdx, {&f});

    // Run the main loop.
    double C = dt/dx;
    while (!timeManager.isFinished()) {
        newIdx = oldIdx+1; halfIdx = oldIdx+0.5;
        for (int i = mesh.is(HALF); i <= mesh.ie(HALF); ++i) {
            fu(i) = 0.5*C*(      u(halfIdx, i)    *(3*f(oldIdx, i)-f(oldIdx, i-1))-
                           C*pow(u(halfIdx, i), 2)*(  f(oldIdx, i)-f(oldIdx, i-1)));
        }
        fu.applyBndCond();
        for (int i = mesh.is(FULL); i <= mesh.ie(FULL); ++i) {
            f(newIdx, i) = f(oldIdx, i)-(fu(i)-fu(i-1));
        }
        f.applyBndCond(newIdx);
        timeManager.advance(); oldIdx.shift();
        io.output<double, 2>(outputFileIdx, oldIdx, {&f});
    }

    return 0;
}