11package org .hobbit .sdk .examples .dummybenchmark .test ;
22
3+ import org .apache .commons .io .FileUtils ;
4+ import org .apache .jena .rdf .model .Model ;
5+ import org .apache .jena .rdf .model .Resource ;
36import org .hobbit .core .Constants ;
47import org .hobbit .core .components .Component ;
8+ import org .hobbit .core .rabbit .RabbitMQUtils ;
59import org .hobbit .sdk .utils .ComponentsExecutor ;
610import org .hobbit .sdk .EnvironmentVariablesWrapper ;
711import org .hobbit .sdk .JenaKeyValue ;
12+ import org .hobbit .sdk .utils .ModelsHandler ;
813import org .hobbit .sdk .utils .MultiThreadedImageBuilder ;
914import org .hobbit .sdk .docker .RabbitMqDockerizer ;
1015import org .hobbit .sdk .docker .builders .hobbit .*;
1318import org .hobbit .sdk .utils .commandreactions .CommandReactionsBuilder ;
1419import org .junit .Assert ;
1520
21+ import java .io .File ;
22+ import java .io .IOException ;
1623import java .util .Date ;
1724
1825import static org .hobbit .core .Constants .*;
@@ -137,8 +144,8 @@ private void checkHealth(Boolean dockerize) throws Exception {
137144 String benchmarkContainerId = "benchmark" ;
138145 String systemContainerId = "system" ;
139146
140- benchmarkContainerId = commandQueueListener .createContainer (benchmarkBuilder .getImageName (), "benchmark" , new String []{ HOBBIT_EXPERIMENT_URI_KEY +"=" +NEW_EXPERIMENT_URI , BENCHMARK_PARAMETERS_MODEL_KEY +"=" + createBenchmarkParameters (). encodeToString ( ) });
141- systemContainerId = commandQueueListener .createContainer (systemAdapterBuilder .getImageName (), "system" ,new String []{ SYSTEM_PARAMETERS_MODEL_KEY +"=" + createSystemParameters (). encodeToString ( ) });
147+ benchmarkContainerId = commandQueueListener .createContainer (benchmarkBuilder .getImageName (), "benchmark" , new String []{ HOBBIT_EXPERIMENT_URI_KEY +"=" +NEW_EXPERIMENT_URI , BENCHMARK_PARAMETERS_MODEL_KEY +"=" + RabbitMQUtils . writeModel2String ( createBenchmarkParameters ()) });
148+ systemContainerId = commandQueueListener .createContainer (systemAdapterBuilder .getImageName (), "system" ,new String []{ SYSTEM_PARAMETERS_MODEL_KEY +"=" + RabbitMQUtils . writeModel2String ( createSystemParameters ()) });
142149
143150 //componentsExecutor.submit(benchmarkController, benchmarkContainerId, new String[]{ HOBBIT_EXPERIMENT_URI_KEY+"="+EXPERIMENT_URI, BENCHMARK_PARAMETERS_MODEL_KEY+"="+ createBenchmarkParameters() });
144151 //componentsExecutor.submit(systemAdapter, systemContainerId, new String[]{ SYSTEM_PARAMETERS_MODEL_KEY+"="+ createSystemParameters() });
@@ -155,19 +162,43 @@ private void checkHealth(Boolean dockerize) throws Exception {
155162 Assert .assertFalse (componentsExecutor .anyExceptions ());
156163 }
157164
165+ public static Model createBenchmarkParameters () throws IOException {
166+ byte [] bytes = FileUtils .readFileToByteArray (new File ("benchmark.ttl" ));
167+ Model model = ModelsHandler .byteArrayToModel (bytes , "TTL" );
168+
169+ Resource experimentResource = model .createResource (org .hobbit .core .Constants .NEW_EXPERIMENT_URI );
170+
171+ int houses_count = 10000 ;
172+ //model.add(benchmarkInstanceResource, model.createProperty(BENCHMARK_URI+"#SPARQL_ENDPOINT_URL"), "http://172.17.0.2:8890/sparql");
173+ model .add (experimentResource , model .createProperty (BENCHMARK_URI +"#messages" ), model .createTypedLiteral ("100" , "xsd:unsignedInt" ));
174+
175+ ModelsHandler .fillTheInstanceWithDefaultModelValues (model , experimentResource , BENCHMARK_URI );
176+
177+ return model ;
158178
159- public static JenaKeyValue createBenchmarkParameters (){
160- JenaKeyValue kv = new JenaKeyValue (NEW_EXPERIMENT_URI );
161- kv .setValue (BENCHMARK_URI +"#messages" , 1000 );
162- return kv ;
163179 }
164180
165- public static JenaKeyValue createSystemParameters (){
166- JenaKeyValue kv = new JenaKeyValue (NEW_EXPERIMENT_URI );
167- kv .setValue (SYSTEM_URI +"systemParam1" , 123 );
168- //kv.setValue(SYSTEM_URI+SYSTEM_CONTAINERS_COUNT_KEY, 2);
169- return kv ;
181+ public static Model createSystemParameters () throws IOException {
182+ byte [] bytes = FileUtils .readFileToByteArray (new File ("system.ttl" ));
183+ Model model = ModelsHandler .byteArrayToModel (bytes , "TTL" );
184+
185+ Resource experimentInstanceResource = model .createResource (org .hobbit .core .Constants .NEW_EXPERIMENT_URI );
186+ //model.add(benchmarkInstanceResource, model.createProperty(BENCHMARK_URI+"#neptuneInstanceType"), model.createTypedLiteral("db.r4.2xlarge", "xsd:string"));
187+ return model ;
170188 }
171189
190+ // public static JenaKeyValue createBenchmarkParameters(){
191+ // JenaKeyValue kv = new JenaKeyValue(NEW_EXPERIMENT_URI);
192+ // kv.setValue(BENCHMARK_URI+"#messages", 1000);
193+ // return kv;
194+ // }
195+ //
196+ // public static JenaKeyValue createSystemParameters(){
197+ // JenaKeyValue kv = new JenaKeyValue(NEW_EXPERIMENT_URI);
198+ // kv.setValue(SYSTEM_URI+"systemParam1", 123);
199+ // //kv.setValue(SYSTEM_URI+SYSTEM_CONTAINERS_COUNT_KEY, 2);
200+ // return kv;
201+ // }
202+
172203
173204}
0 commit comments