static OH::Storage* createCassandraStorage(ObjectHostContext* ctx, const String& args) { OptionSet* optionsSet = OptionSet::getOptions("cassandrastorage",NULL); optionsSet->parse(args); String host = optionsSet->referenceOption("host")->as<String>(); int32 port = optionsSet->referenceOption("port")->as<int32>(); return new OH::CassandraStorage(ctx, host, port); }
static ObjectFactory* createCassandraObjectFactory(ObjectHostContext* ctx, ObjectHost* oh, const SpaceID& space, const String& args) { OptionSet* optionsSet = OptionSet::getOptions("cassandrafactory",NULL); optionsSet->parse(args); String host = optionsSet->referenceOption("host")->as<String>(); int32 port = optionsSet->referenceOption("port")->as<int32>(); String ohid = optionsSet->referenceOption("ohid")->as<String>(); return new CassandraObjectFactory(ctx, oh, space, host, port, ohid); }
static OH::PersistedObjectSet* createCassandraPersistedObjectSet(ObjectHostContext* ctx, const String& args) { OptionSet* optionsSet = OptionSet::getOptions("cassandrapersistedset",NULL); optionsSet->parse(args); String host = optionsSet->referenceOption("host")->as<String>(); int32 port = optionsSet->referenceOption("port")->as<int32>(); String ohid = optionsSet->referenceOption("ohid")->as<String>(); return new OH::CassandraPersistedObjectSet(ctx, host, port, ohid); }
SaveFilter::SaveFilter(const String& args) { Sirikata::InitializeClassOptions ico("save_filter", NULL, new OptionValue("filename","",Sirikata::OptionValueType<String>(),"Name of file to save to."), new OptionValue("format","colladamodels",Sirikata::OptionValueType<String>(),"Format to save to."), NULL); OptionSet* optionSet = OptionSet::getOptions("save_filter",NULL); optionSet->parse(args); mFilename = optionSet->referenceOption("filename")->as<String>(); mFormat = optionSet->referenceOption("format")->as<String>(); }
ByteTransferScenario::ByteTransferScenario(const String &options):mStartTime(Time::epoch()){ mNumTotalPings=0; mContext=NULL; mObjectTracker = NULL; BTSInitOptions(this); OptionSet* optionsSet = OptionSet::getOptions("DistributedPingScenario",this); optionsSet->parse(options); mSameObjectHostPings=optionsSet->referenceOption("allow-same-object-host")->as<bool>(); mForceSameObjectHostPings=optionsSet->referenceOption("force-same-object-host")->as<bool>(); mPacketSize=optionsSet->referenceOption("packet-size")->as<size_t>(); mPort=OBJECT_PORT_PING; mGeneratePings=std::tr1::bind(&ByteTransferScenario::generatePings,this); }
OSegScenario::OSegScenario(const String &options) : mStartTime(Time::epoch()) { mNumTotalPings=0; mContext=NULL; mObjectTracker = NULL; mPingID=0; DPSInitOptions(this); OptionSet* optionsSet = OptionSet::getOptions("OSegScenario",this); optionsSet->parse(options); mNumPingsPerSecond=optionsSet->referenceOption("num-pings-per-second")->as<double>(); mPingPayloadSize=optionsSet->referenceOption("ping-size")->as<uint32>(); mFloodServer = optionsSet->referenceOption("flood-server")->as<uint32>(); mSourceFloodServer = optionsSet->referenceOption("source-flood-server")->as<bool>(); mNumObjectsPerServer=optionsSet->referenceOption("num-objects-per-server")->as<uint32>(); mLocalTraffic = optionsSet->referenceOption("local")->as<bool>(); mFractionMessagesUniform= optionsSet->referenceOption("prob-messages-uniform")->as<double>(); mNumGeneratedPings = 0; mGeneratePingsStrand = NULL; mGeneratePingPoller = NULL; mPings = // We allocate space for 1/4 seconds worth of pings new Sirikata::SizedThreadSafeQueue<PingInfo,CountResourceMonitor>( CountResourceMonitor(std::max((uint32)(mNumPingsPerSecond / 4), (uint32)2)) ); mWeightCalculator = RegionWeightCalculatorFactory::getSingleton().getConstructor(GetOptionValue<String>(OPT_REGION_WEIGHT))(GetOptionValue<String>(OPT_REGION_WEIGHT_ARGS)) ; mPingPoller = NULL; // NOTE: We have this limit because we can get in lock-step with the // generator, causing this to run for excessively long when we fall behind // on pings. This allows us to burst to catch up when there is time (and // amortize the constant overhead of doing 1 round), but if // there is other work to be done we won't make our target rate. mMaxPingsPerRound = 40; // Do we want to vary this based on mNumPingsPerSecond? 20 is a decent // burst, but at 10k/s can take 2ms (we're seeing about 100us/ping // currently), which is potentially a long delay for other things in this // strand. If we try to get to 100k, that can be up to 20ms which is very // long to block other things on the main strand. }
OptionValue* GetOption(const char* klass, const char* name) { OptionSet* options = OptionSet::getOptions(klass,NULL); return options->referenceOption(name); }
OptionValue* GetOption(const char* name) { OptionSet* options = OptionSet::getOptions(SIRIKATA_OPTIONS_MODULE,NULL); return options->referenceOption(name); }