//###
//# #%L
//# mosaic-java-benchmarks
//# %%
//# Copyright (C) 2010 - 2012 Seconda Università di Napoli
//#Authors: Massimiliano Rak, Giuseppe Aversano, Loredana Liccardo
//# %%
//# Licensed under the Apache License, Version 2.0 (the "License");
//# you may not use this file except in compliance with the License.
//# You may obtain a copy of the License at
//#
//# http://www.apache.org/licenses/LICENSE-2.0
//#
//# Unless required by applicable law or agreed to in writing, software
//# distributed under the License is distributed on an "AS IS" BASIS,
//# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//# See the License for the specific language governing permissions and
//# limitations under the License.
//# #L%
//###
package eu.mosaic_cloud.sla;
//import mosaic.cloudlet.core.CallbackArguments;
import java.util.*;
import eu.mosaic_cloud.cloudlets.core.CallbackArguments;
import eu.mosaic_cloud.cloudlets.core.CloudletCallbackCompletionArguments;
import eu.mosaic_cloud.cloudlets.core.CloudletCallbackArguments;
import eu.mosaic_cloud.cloudlets.core.GenericCallbackCompletionArguments;
import eu.mosaic_cloud.cloudlets.tools.DefaultCloudletCallback;
import eu.mosaic_cloud.cloudlets.core.ICallback;
import eu.mosaic_cloud.cloudlets.core.ICloudletController;
//import mosaic.cloudlet.core.DefaultCloudletCallback;
//import mosaic.cloudlet.core.ICloudletController;
//import mosaic.cloudlet.resources.amqp.AmqpQueueConsumeCallbackArguments;
//import mosaic.cloudlet.resources.amqp.AmqpQueueConsumeMessage;
//import mosaic.cloudlet.resources.amqp.AmqpQueueConsumer;
//import mosaic.cloudlet.resources.amqp.AmqpQueuePublishCallbackArguments;
//import mosaic.cloudlet.resources.amqp.AmqpQueuePublisher;
//import mosaic.cloudlet.resources.amqp.DefaultAmqpConsumerCallback;
//import mosaic.cloudlet.resources.amqp.DefaultAmqpPublisherCallback;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.AmqpQueueConsumeCallbackArguments;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueueConsumerConnector;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueueConsumerConnectorFactory;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueuePublisherConnector;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueuePublisherConnectorFactory;
import eu.mosaic_cloud.cloudlets.tools.DefaultAmqpPublisherConnectorCallback;
import eu.mosaic_cloud.cloudlets.tools.DefaultAmqpQueueConsumerConnectorCallback;
//import mosaic.cloudlet.resources.kvstore.DefaultKeyValueAccessorCallback;
//import mosaic.cloudlet.resources.kvstore.IKeyValueAccessor;
//import mosaic.cloudlet.resources.kvstore.KeyValueAccessor;
//import mosaic.cloudlet.resources.kvstore.KeyValueCallbackArguments;
import eu.mosaic_cloud.cloudlets.connectors.kvstore.IKvStoreConnector;
import eu.mosaic_cloud.cloudlets.connectors.kvstore.IKvStoreConnectorFactory;
import eu.mosaic_cloud.cloudlets.connectors.kvstore.KvStoreCallbackCompletionArguments;
import eu.mosaic_cloud.cloudlets.tools.DefaultKvStoreConnectorCallback;
//import eu.mosaic_cloud.examples.cloudlets.simple.SLAPolicyCloudlet.SLAPolicyCloudletContext;
//import eu.mosaic_cloud.examples.cloudlets.simple.SLAStoreInt.AmqpConsumerCallback;
//import eu.mosaic_cloud.examples.cloudlets.simple.SLAStoreInt.AmqpPublisherCallback;
//import eu.mosaic_cloud.examples.cloudlets.simple.SLAStoreInt.KeyValueCallbackinfow;
//import eu.mosaic_cloud.examples.cloudlets.simple.SLAStoreInt.SLAStoreIntContext;
//import mosaic.core.configuration.ConfigurationIdentifier;
//import mosaic.core.configuration.IConfiguration;
//import mosaic.core.log.MosaicLogger;
//import mosaic.core.utils.DataEncoder;
//import mosaic.core.utils.JsonDataEncoder;
//import mosaic.core.utils.PojoDataEncoder;
import eu.mosaic_cloud.platform.core.configuration.ConfigurationIdentifier;
import eu.mosaic_cloud.platform.core.configuration.IConfiguration;
import eu.mosaic_cloud.platform.core.utils.JsonDataEncoder;
import eu.mosaic_cloud.platform.core.utils.NullDataEncoder;
import eu.mosaic_cloud.platform.core.utils.PlainTextDataEncoder;
import eu.mosaic_cloud.platform.core.utils.SerializedDataEncoder;
import eu.mosaic_cloud.tools.callbacks.core.CallbackCompletion;
import java.io.UnsupportedEncodingException;
import java.lang.Object;
import com.google.gson.Gson;
import org.apache.commons.jexl.*;
public class TradeStateCA_dev10 {
public static final class LifeCycleHandler extends
DefaultCloudletCallback<TradeStateIntContext > {
public CallbackCompletion<Void> initialize(final TradeStateIntContext context, final CloudletCallbackArguments<TradeStateIntContext> arguments) {
this.logger.info(
"CloudletTradeState is being initialized.");
context.cloudlet = arguments.getCloudlet ();
final IConfiguration configuration = context.cloudlet.getConfiguration ();
final IConfiguration configuration2 = context.cloudlet.getConfiguration ();
final IConfiguration configuration3 = context.cloudlet.getConfiguration ();
final IConfiguration configuration4 = context.cloudlet.getConfiguration ();
final IConfiguration configuration5 = context.cloudlet.getConfiguration ();
final IConfiguration configuration6 = context.cloudlet.getConfiguration ();
/*
final IConfiguration queueConfiguration = configuration
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queuestate"));
context.consumer = context.cloudlet.getConnectorFactory
(IAmqpQueueConsumerConnectorFactory.class).create
(queueConfiguration, String.class, JsonDataEncoder.create
(String.class), new AmqpConsumerCallbackState (), context);
*/
/*
final IConfiguration queueConfigurationb = configuration2
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queueevaluate"));
context.publisher = context.cloudlet.getConnectorFactory
(IAmqpQueuePublisherConnectorFactory.class).create
(queueConfigurationb, String.class, JsonDataEncoder.create
(String.class), new AmqpPublisherCallbackEvaluate (), context);
*/
final IConfiguration queueConfiguration3 = configuration3
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queueinter"));
context.consumerslagw = context.cloudlet.getConnectorFactory
(IAmqpQueueConsumerConnectorFactory.class).create
(queueConfiguration3, byte[].class, NullDataEncoder.create(),
new AmqpConsumerCallbackSLAgw (), context);
final IConfiguration queueConfiguration4 = configuration4
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queueresponce"));
context.consumerresponce = context.cloudlet.getConnectorFactory
(IAmqpQueueConsumerConnectorFactory.class).create
(queueConfiguration4,String.class, JsonDataEncoder.create
(String.class), new AmqpConsumerCallbackResponce (), context);
final IConfiguration queueConfigurationb5 = configuration5
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queueslastore"));
context.publisherslastore = context.cloudlet.getConnectorFactory
(IAmqpQueuePublisherConnectorFactory.class).create
(queueConfigurationb5, String.class, JsonDataEncoder.create
(String.class), new AmqpPublisherCallbackSlaStore (), context);
final IConfiguration queueConfigurationb6 = configuration6
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queuecagw"));
context.publishercagw = context.cloudlet.getConnectorFactory
(IAmqpQueuePublisherConnectorFactory.class).create
(queueConfigurationb6, String.class, JsonDataEncoder.create
(String.class), new AmqpPublisherCallbackCAgw(), context);
final IConfiguration kvConfiguration = configuration
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("statestore"));
context.kvStore = context.cloudlet.getConnectorFactory
(IKvStoreConnectorFactory.class).create
(kvConfiguration, String.class, JsonDataEncoder.create
(String.class), new KeyValueCallbackstatostore (), context);
final IConfiguration kvConfiguration2 = configuration
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("slastore"));
context.kvStoresla = context.cloudlet.getConnectorFactory
(IKvStoreConnectorFactory.class).create
(kvConfiguration2, String.class, JsonDataEncoder.create
(String.class), new KeyValueCallbackslastore (), context);
// kvStore Aggiunto per l'interfaccia grafica
final IConfiguration kvConfiguration3 = configuration
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("mhttpgwkv"));
context.kvStoremhttpgw = context.cloudlet.getConnectorFactory
(IKvStoreConnectorFactory.class).create
(kvConfiguration3, String.class, JsonDataEncoder.create
(String.class), new KeyValueCallbackmhttpgw (), context);
//Fine kv grafico
// kvStore Aggiunto per xml grafica
final IConfiguration kvConfiguration4 = configuration
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("xmlstore"));
context.kvStorexml = context.cloudlet.getConnectorFactory
(IKvStoreConnectorFactory.class).create
(kvConfiguration4, String.class,PlainTextDataEncoder.DEFAULT_INSTANCE,
new KeyValueCallbackxml (), context);
//Fine kv xml
/////return CallbackCompletion.createAndChained (context.kvStore.initialize (),context.kvStoremhttpgw.initialize (),context.kvStoresla.initialize (),context.kvStorexml.initialize (),context.consumer.initialize(),context.consumerresponce.initialize(), context.consumerslagw.initialize(), context.publisher.initialize (),context.publishercagw.initialize(), context.publisherslastore.initialize());
return CallbackCompletion.createAndChained (context.kvStore.initialize (),context.kvStoresla.initialize (),context.kvStoremhttpgw.initialize (),context.kvStorexml.initialize(),context.consumerslagw.initialize(),context.consumerresponce.initialize(),context.publishercagw.initialize(), context.publisherslastore.initialize());
}
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context, final CloudletCallbackCompletionArguments<TradeStateIntContext> arguments) {
this.logger.info(
"CloudletTradeState initialized successfully.");
context.WSAG.setSize(400);
context.object=new JsonObjectfromString();
context.objectaction=new JsonObjectfromStringAction();
context.objectwsag= new JsonObjectfromStringWSAG() ;
context.object_1=new JsonObjectfromStringStato();
context.gson=new Gson();
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> destroy(final TradeStateIntContext context, final CloudletCallbackArguments<TradeStateIntContext> arguments) {
this.logger
.info("CloudletTradeState is being destroyed.");
return CallbackCompletion.createAndChained (context.kvStore.destroy(),context.kvStoremhttpgw.destroy(),context.kvStoresla.destroy(),context.kvStorexml.destroy(),context.publishercagw.destroy(),context.publisherslastore.destroy(),context.consumerresponce.destroy(),context.consumerslagw.destroy());
////return CallbackCompletion.createAndChained (context.kvStore.destroy(),context.kvStoremhttpgw.destroy(),context.kvStoresla.destroy(),context.publisher.destroy(),context.publishercagw.destroy(),context.publisherslastore.destroy(),context.consumer.destroy(),context.consumerresponce.destroy());
}
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context, final CloudletCallbackCompletionArguments<TradeStateIntContext > arguments) {
this.logger.info(
"CloudletTradeState was destroyed successfully.");
return ICallback.SUCCESS;
}
}
// KVStoreState (Stato)
public static final class KeyValueCallbackstatostore extends
DefaultKvStoreConnectorCallback<TradeStateIntContext, String, Void> {
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger
.info("KeyValueState accessor initialized successfully");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> setSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("SetSucceeded KVState");
String k=arguments.getKey();
this.logger.info("KEY: "+k);
String sta=(String)arguments.getValue();
this.logger.info("Stato: "+sta);
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> deleteSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> getSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("GetSucceeded KVState da parte di TRADESTATE");
String k=arguments.getKey();
this.logger.info("KEY "+k);
String p=null;
if (arguments.getValue()==null){
p=new String("");}
else {
p=new String(arguments.getValue());}
this.logger.info("STATO "+p);
int pos = Integer.parseInt(k);
String vall=context.WSAG.get(pos);
this.logger.info("Messaggio Ricevuto nel Get da TRADESTATE:"+vall);
context.objectwsag=context.gson.fromJson(vall,JsonObjectfromStringWSAG.class);
if((context.objectwsag.getType().equals("SubmitCFP")) && (p.equals(""))){
String template=null;
template=context.objectwsag.getWSAG();
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SubmittedSLA, template , null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'SubmitCFP','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Evaluating'}", null);
context.kvStore.set(context.objectwsag.getId(),"Evaluating", null);
// this.logger.info("{'action':'"+context.objectwsag.getAction()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}");
context.publishercagw.publish("{'type':'SubmitCFP','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}", null);
this.logger.info("TradeState Push SubmitCFP a SLASTORE");
context.publisherslastore.publish("{'type':'Submit','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
context.concatenazioneclaint=context.concatenazioneclaint+"\n\n"+context.objectwsag.getWSAG();
}
if((context.objectwsag.getType().equals("SubmitCFP")) && (p.equals("OptionsAvailable"))){
String template=null;
template=context.objectwsag.getWSAG();
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SubmittedSLA, template, null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'SubmitCFP','StateWS':''}", null);
this.logger.info("TradeState Push SubmitCFP a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Evaluating'}", null);
context.kvStore.set(context.objectwsag.getId(),"Evaluating", null);
//this.logger.info("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}");
context.publishercagw.publish("{'type':'SubmitCFP','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}", null);
context.concatenazioneclaint=context.concatenazioneclaint+"\n\n"+context.objectwsag.getWSAG();
}
if((context.objectwsag.getType().equals("SubmitProposal")) && (p.equals("OptionsAvailable"))){
String template=null;
template=context.objectwsag.getWSAG();
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SelectedCAProposal, template, null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'SubmitProposal','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Reserveting'}", null);
context.kvStore.set(context.objectwsag.getId(),"Reserveting", null);
context.publishercagw.publish("{'type':'SubmitProposal','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}", null);
this.logger.info("TradeState Push Submit a SLASTORE");
context.publisherslastore.publish("{'type':'Submit','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
}
if((context.objectwsag.getType().equals("Sign")) && (p.equals("Reserved"))){
String template=null;
template=context.objectwsag.getWSAG();
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SelectedCAProposal, template, null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Sign','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Signing'}", null);
context.kvStore.set(context.objectwsag.getId(),"Signing", null);
context.publishercagw.publish("{'type':'Sign','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}", null);
this.logger.info("TradeState Push Sign a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//sono qui
}
if((context.objectwsag.getType().equals("Terminate")) && (p.equals("Signed"))){
String template=null;
String proposal=null;
template=context.objectwsag.getWSAG();
//proposal=context.cp2;
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] proposal=null;
try {
proposal = context.cp2.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SelectedClientProposal, template, null);
//context.kvStorexml.set(context.SelectedCAProposal, proposal, null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Terminate','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Terminating'}", null);
context.kvStore.set(context.objectwsag.getId(),"Terminating", null);
context.publishercagw.publish("{'type':'Terminate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}", null);
this.logger.info("TradeState Push Terminate a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
/*
context.kvStore.set(context.objectaction.getId(),null, null);
context.concatenazione="";
context.concatenazioneclaint="";
context.step=0;
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':''}" , null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'','StateWS':''}", null);
String reset1="";
/*
byte[] reset1=null;
try {
reset1 = state.app1.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
/*
context.kvStorexml.set(context.CACFP1, reset1, null);
context.kvStorexml.set(context.CACFP2, reset1, null);
context.kvStorexml.set(context.CACFP3, reset1, null);
context.kvStorexml.set(context.SubmittedSLA, reset1, null);
context.kvStorexml.set(context.SelectedClientProposal, reset1, null);
context.kvStorexml.set(context.SelectedCAProposal, reset1, null);
context.kvStorexml.set(context.CAProposal, reset1, null);
context.kvStorexml.set(context.ClientProposal, reset1, null);
*/
}
//}
//Fine
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> ungetSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("ungetSucceeded");
this.logger.info("ungetSucceeded");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
}
// KVStoreSLAStore (WSAG)
public static final class KeyValueCallbackslastore extends
DefaultKvStoreConnectorCallback<TradeStateIntContext, String, Void> {
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger
.info("KeyValueSLAstore accessor initialized successfully");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> setSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("SetSucceeded KeyValueSLAstore");
//System.out.println("\n\nSetSucceeded KeyValueSLAstore\n\n");
String k=arguments.getKey();
//System.out.println("\n\nKEY:"+k);
//System.out.println("\n\n");
String sta=(String)arguments.getValue();
//System.out.println("\n\nStato:"+sta);
//System.out.println("\n\n");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> deleteSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("\n\n KeyValueSLAstore Delete succeeded\n\n ");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> getSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("GetSucceeded KeyValueSLAstore");
//System.out.println("\n\nGetSucceeded KeyValueSLAstore\n\n");
String k=arguments.getKey();
//System.out.println("\n\nKEY:"+k);
//System.out.println("\n\n");
String p=(String)arguments.getValue();
//System.out.println("\n\ninfo_WSAG:"+p);
context.object_1=context.gson.fromJson(p,JsonObjectfromStringStato.class);
String mem="{'id':'"+context.object_1.getId()+"','stato':'"+context.object_1.getStato()+"','wsag':'"+context.concatenazioneclaint+"'}";
context.kvStoresla.set(context.object_1.getId(),mem,null);
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> ungetSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("ungetSucceeded");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
}
//KV Aggiunta per l'interfaccia grafica
// KVStoreMHTTPGW (interfaccia grafica)
public static final class KeyValueCallbackmhttpgw extends
DefaultKvStoreConnectorCallback<TradeStateIntContext, String, Void> {
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger
.info("KeyValueMHTTPGW initialized successfully");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> setSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("SetSucceeded KeyValueMHTTPGW");
//System.out.println("\n\nSetSucceeded KeyValueMHTTPGW\n\n");
String k1=arguments.getKey();
this.logger.info("KEY KeyValueMHTTPGW: "+k1);
//System.out.println("\n\nKEY KeyValueMHTTPGW:"+k1);
//System.out.println("\n\n");
String sta2=(String)arguments.getValue();
this.logger.info("Valore KeyValueMHTTPGW: "+sta2);
//System.out.println("\n\nValore KeyValueMHTTPGW:"+sta2);
//System.out.println("\n\n");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> deleteSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("\n\n KeyValueMHTTPGW Delete succeeded\n\n ");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> getSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("GetSucceeded KeyValueMHTTPGW");
//System.out.println("\n\nGetSucceeded KeyValueMHTTPGW\n\n");
String k=arguments.getKey();
//System.out.println("\n\nKEY:"+k);
//System.out.println("\n\n");
String p=(String)arguments.getValue();
//System.out.println("\n\nValore:"+p);
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> ungetSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("ungetSucceeded");
this.logger.info("ungetSucceeded");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
}
//Fine aggiunta per l'interfaccia grafica
// KV Aggiunta per xml grafica
// KVStorexml (xml grafica)
public static final class KeyValueCallbackxml extends
DefaultKvStoreConnectorCallback<TradeStateIntContext,String, Void> {
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger
.info("KeyValuexml initialized successfully");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> setSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("SetSucceeded KeyValuexml");
//System.out.println("\n\nSetSucceeded KeyValuexml\n\n");
String k1=arguments.getKey();
this.logger.info("KEY KeyValueMHTTPGWxml: "+k1);
//System.out.println("\n\nKEY KeyValueMHTTPGW:"+k1);
//System.out.println("\n\n");
//String sta2=(String)arguments.getValue();
//System.out.println("\n\nValore KeyValueMHTTPGW:"+sta2);
//System.out.println("\n\n");
String sta2=(String)arguments.getValue();
this.logger.info("Valore KeyValueMHTTPGWxml: "+sta2);
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> deleteSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("\n\n KeyValuexml Delete succeeded\n\n ");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> getSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("GetSucceeded KeyValuexml");
//System.out.println("\n\nGetSucceeded KeyValuexml\n\n");
String k=arguments.getKey();
//System.out.println("\n\nKEY:"+k);
// System.out.println("\n\n");
//String p=(String)arguments.getValue();
//System.out.println("\n\nValore:"+p);
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> ungetSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
//System.out.println("ungetSucceeded");
this.logger.info("ungetSucceeded");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
}
//Fine aggiunta per xml grafica
// QuequeState(Consumer)
/*public static final class AmqpConsumerCallbackState extends
DefaultAmqpQueueConsumerConnectorCallback<TradeStateIntContext, String, Void>
{
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletState initialized successfully.");
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletState was destroyed successfully.");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<String> arguments){
/* final String data = arguments.getMessage ();
this.logger.info(
"ConsumerCloudletState received message from SLAPolicy "
+ data);
this.logger.info("Message Ricevuto da SLAPolicy:"+data);
context.objectaction=context.gson.fromJson(data,JsonObjectfromStringAction.class);
this.logger.info("Azione da intraprendere: "+context.objectaction.getAction());
this.logger.info("WSAG:"+context.objectaction.getWSAG());
this.logger.info("ID e Nuovo Stato: "+context.objectaction.getId()+","+context.objectaction.getNewState());
context.kvStore.set(context.objectaction.getId(),context.objectaction.getNewState(), null);
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (context.objectaction.getNewState().equals("NewCFP")){
context.CFPs=context.cfp.Genera(context.objectaction.getWSAG());
for(int i=0;i<context.CFPs.size();i++){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAcfpSent','Action':'"+context.objectaction.getAction()+"','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':'"+context.objectaction.getAction()+"'}", null);
// Fine aggiunto per l'interfaccia grafica
if (i==0){
byte[] cfpb1=null;
try {
cfpb1 = context.CFPs.get(0).getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStorexml.set(context.CACFP1, cfpb1, null);
}
if (i==1){
byte[] cfpb2=null;
try {
cfpb2 = context.CFPs.get(1).getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStorexml.set(context.CACFP2, cfpb2, null);
}
if (i==2){
byte[] cfpb3=null;
try {
cfpb3 = context.CFPs.get(2).getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStorexml.set(context.CACFP3, cfpb3, null);
}
//System.out.println("\nTRADESTATE invia a CAgw:\n");
this.logger.info("TRADESTATE invia a CAgw:");
//System.out.println("\n{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.CFPs.get(i)+"'}\n");
this.logger.info("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.CFPs.get(i)+"'}");
context.publishercagw.publish("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.CFPs.get(i)+"'}", null);
}
//System.out.println("\nTRADESTATE invia a SLAPolicy:\n");
this.logger.info("TRADESTATE invia a SLAPolicy:");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAcfpSent','rules':['Parametri','Expression','Action']}\n");
this.logger.info("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAcfpSent','rules':['Parametri','Expression','Action']}");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAcfpSent','rules':['Parametri','Expression','Action']}", null);
}
if (context.objectaction.getNewState().equals("OptionsAvailable")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
qui.
if (context.objectaction.getNewState().equals("ReserveRequest")){
//Aggiunto per l'interfaccia grafica
//context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAreserveSent','Action':'"+context.objectaction.getAction()+"','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':'"+context.objectaction.getAction()+"'}", null);
// Fine aggiunto per l'interfaccia grafica
//System.out.println("\nTRADESTATE invia a CAgw:\n");
this.logger.info("TRADESTATE invia a CAgw:");
//System.out.println("\n{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}\n");
this.logger.info("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}");
context.publishercagw.publish("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}", null);
//System.out.println("\nTRADESTATE invia a SLAPolicy:\n");
this.logger.info("TRADESTATE invia a SLAPolicy:");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAreserveSent','rules':['Parametri','Expression','Action']}\n");
this.logger.info("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAreserveSent','rules':['Parametri','Expression','Action']}");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAreserveSent','rules':['Parametri','Expression','Action']}", null);
}
if (context.objectaction.getNewState().equals("Reserveting")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
if (context.objectaction.getNewState().equals("Reserved")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
if (context.objectaction.getNewState().equals("SignRequest")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAsignSent','Action':'"+context.objectaction.getAction()+"','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':'"+context.objectaction.getAction()+"'}", null);
// Fine aggiunto per l'interfaccia grafica
//System.out.println("\nTRADESTATE invia a CAgw:\n");
this.logger.info("TRADESTATE invia a CAgw:");
//System.out.println("\n{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}\n");
this.logger.info("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}");
context.publishercagw.publish("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}", null);
//System.out.println("\nTRADESTATE invia a SLAPolicy:\n");
this.logger.info("TRADESTATE invia a SLAPolicy:");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAsignSent','rules':['Parametri','Expression','Action']}\n");
this.logger.info("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAsignSent','rules':['Parametri','Expression','Action']}");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAsignSent','rules':['Parametri','Expression','Action']}", null);
}
if (context.objectaction.getNewState().equals("Signing")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
if (context.objectaction.getNewState().equals("Signed")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
if (context.objectaction.getNewState().equals("TerminateRequest")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAterminateSent','Action':'"+context.objectaction.getAction()+"','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':'"+context.objectaction.getAction()+"'}", null);
// Fine aggiunto per l'interfaccia grafica
//System.out.println("\nTRADESTATE invia a CAgw:\n");
this.logger.info("TRADESTATE invia a CAgw:");
//System.out.println("\n{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}\n");
this.logger.info("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}");
context.publishercagw.publish("{'action':'"+context.objectaction.getAction()+"','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"'}", null);
//System.out.println("\nTRADESTATE invia a SLAPolicy:\n");
this.logger.info("TRADESTATE invia a SLAPolicy:");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAterminateSent','rules':['Parametri','Expression','Action']}\n");
this.logger.info("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAterminateSent','rules':['Parametri','Expression','Action']}");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAterminateSent','rules':['Parametri','Expression','Action']}", null);
}
if (context.objectaction.getNewState().equals("Terminating")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'Wait','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
}
if (context.objectaction.getNewState().equals("Terminated")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'End','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
//System.out.println("\n\nNegoziazione Terminata\n\n");
this.logger.info("Negoziazione Terminata");
/*
//Aggiunta di notte
state.kvStore.set(state.objectaction.getId(),null, null);
state.concatenazione="";
state.concatenazioneclaint="";
state.step=0;
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
state.kvStoremhttpgw.set(state.Negotiation,"{'SendSLAPolicy':'','Action':'','StateNegotiation':'','SendCA':''}", null);
state.kvStoremhttpgw.set(state.CA,"{'ResponseCA':''}" , null);
state.kvStoremhttpgw.set(state.Clientbe,"{'RequestClient':'','StateWS':''}", null);
byte[] reset1=null;
try {
reset1 = state.app1.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
state.kvStorexml.set(state.CACFP1, reset1, null);
state.kvStorexml.set(state.CACFP2, reset1, null);
state.kvStorexml.set(state.CACFP3, reset1, null);
state.kvStorexml.set(state.SubmittedSLA, reset1, null);
state.kvStorexml.set(state.SelectedClientProposal, reset1, null);
state.kvStorexml.set(state.SelectedCAProposal, reset1, null);
state.kvStorexml.set(state.CAProposal, reset1, null);
state.kvStorexml.set(state.ClientProposal, reset1, null);
//Fine aggiunta di notte
}
//Aggiunto dopo che tutto funzionava
//Inizio
if (context.objectaction.getNewState().equals("Rejected")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'End','StateNegotiation':'"+context.objectaction.getNewState()+"','SendCA':''}", null);
// Fine aggiunto per l'interfaccia grafica
System.out.println("\n\nNegoziazione Non Andata a Buon Fine Stato Rejected\n\n");
//Aggiunta di notte
context.kvStore.set(context.objectaction.getId(),null, null);
context.concatenazione="";
context.concatenazioneclaint="";
context.step=0;
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'','Action':'','StateNegotiation':'','SendCA':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':''}" , null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'','StateWS':''}", null);
byte[] reset1=null;
try {
reset1 = context.app1.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStorexml.set(context.CACFP1, reset1, null);
context.kvStorexml.set(context.CACFP2, reset1, null);
context.kvStorexml.set(context.CACFP3, reset1, null);
context.kvStorexml.set(context.SubmittedSLA, reset1, null);
context.kvStorexml.set(context.SelectedClientProposal, reset1, null);
context.kvStorexml.set(context.SelectedCAProposal, reset1, null);
context.kvStorexml.set(context.CAProposal, reset1, null);
context.kvStorexml.set(context.ClientProposal, reset1, null);
//Fine aggiunta di notte
}
//Fine
context.consumer.acknowledge (arguments.getToken ());
//message.acknowledge();
return ICallback.SUCCESS;
}
}
*/
// QuequeSLAgw (Consumer)
public static final class AmqpConsumerCallbackSLAgw extends
DefaultAmqpQueueConsumerConnectorCallback<TradeStateIntContext, byte[], Void>{
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletEvaluate initialized successfully.");
//state.consumerslagw.register();
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletSLAgw was destroyed successfully.");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<byte[]> arguments){
String data=new String(arguments.getMessage());
this.logger.info(
"ConsumerCloudletSLAgw received message from SLAgw: "
+ data);
this.logger.info("Message Ricevuto da SLAgw");
context.objectwsag=context.gson.fromJson(data,JsonObjectfromStringWSAG.class);
this.logger.info("TYPE "+context.objectwsag.getType());
if(context.objectwsag.getType().equals("Check")){
String template=null;
template=context.objectwsag.getWSAG();
/* byte[] template=null;
try {
template = context.objectwsag.getWSAG().getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.SelectedClientProposal, template, null);
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
}
else
{
context.WSAG.add(Integer.parseInt(context.objectwsag.getId()),data);
context.kvStore.get(context.objectwsag.getId(),null);
}
context.consumerslagw.acknowledge (arguments.getToken ());
return ICallback.SUCCESS;
}
}
// QuequeResponce(Consumer)
public static final class AmqpConsumerCallbackResponce extends
DefaultAmqpQueueConsumerConnectorCallback<TradeStateIntContext, String, Void>
{
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletResponce initialized successfully.");
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletResponce was destroyed successfully.");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<String> arguments){
final String data = arguments.getMessage ();
this.logger.info(
"ConsumerCloudletResponce received message from CAgw "
+ data);
context.objectaction=context.gson.fromJson(data,JsonObjectfromStringAction.class);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(context.objectaction.getAction().equals("CAresponse")){
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAresponse'}" , null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'OptionsAvailable'}", null);
context.kvStore.set(context.objectaction.getId(),"OptionsAvailable", null);
context.concatenazione=context.objectaction.getWSAG();
String pro1=null;
String procl1=null;
pro1=context.concatenazione;
procl1=context.concatenazioneclaint;
/*
byte[] pro1=null;
try {
pro1 = context.concatenazione.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] procl1=null;
try {
procl1 = context.concatenazioneclaint.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.CAProposal, pro1, null);
context.kvStorexml.set(context.ClientProposal, procl1, null);
context.kvStoresla.get(context.objectaction.getId(),null);
}
if(context.objectaction.getAction().equals("CAreserve")){
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAreserve'}" , null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Reserved'}", null);
context.kvStore.set(context.objectaction.getId(),"Reserved", null);
}
if(context.objectaction.getAction().equals("CAsigned")){
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAsigned'}" , null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Signed'}", null);
context.kvStore.set(context.objectaction.getId(),"Signed", null);
//sono qui.
}
if(context.objectaction.getAction().equals("CAterminated")){
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':'Terminated'}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAterminated'}" , null);
context.kvStore.set(context.objectaction.getId(),"Terminated", null);
context.concatenazione="";
context.concatenazioneclaint="";
context.step=0;
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
context.kvStore.set(context.objectaction.getId(),"", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':''}" , null);
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'','StateWS':''}", null);
String reset1="";
/*
byte[] reset1=null;
try {
reset1 = state.app1.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
context.kvStorexml.set(context.CACFP1, reset1, null);
context.kvStorexml.set(context.CACFP2, reset1, null);
context.kvStorexml.set(context.CACFP3, reset1, null);
context.kvStorexml.set(context.SubmittedSLA, reset1, null);
context.kvStorexml.set(context.SelectedClientProposal, reset1, null);
context.kvStorexml.set(context.SelectedCAProposal, reset1, null);
context.kvStorexml.set(context.CAProposal, reset1, null);
context.kvStorexml.set(context.ClientProposal, reset1, null);
}
//Aggiunto dopo il corretto funzionamento
//Inizio
if(context.objectaction.getAction().equals("CAtimeout")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAtimeout'}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAtimeout'}" , null);
//Fine interfaccia grafica
//System.out.println("\nTRADESTATE push SLAPolicy:\n");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAtimeout','rules':['Parametri','Expression','Action']}\n");
// context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAtimeout','rules':['Parametri','Expression','Action']}", null);
}
if(context.objectaction.getAction().equals("CArefused")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'StateNegotiation':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CArefused'}" , null);
//Fine interfaccia grafica
//System.out.println("\nTRADESTATE push SLAPolicy:\n");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CArefused','rules':['Parametri','Expression','Action']}\n");
// context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CArefused','rules':['Parametri','Expression','Action']}", null);
}
//FINE
context.consumerresponce.acknowledge (arguments.getToken ());
//message.acknowledge();
return ICallback.SUCCESS;
}
}
//QuequeEvaluate (Publisher)
/*
public static final class AmqpPublisherCallbackEvaluate
extends
DefaultAmqpPublisherConnectorCallback<TradeStateIntContext, String, Void> {
/*@Override
public void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletEvaluate registered successfully.");
}*/
/*@Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletEvaluate unregistered successfully.");
// if unregistered as publisher is successful then destroy resource
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
//cloudlet.destroyResource(state.publisher, this);
}
@Override
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// if resource initialized successfully then just register as a
// publisher
//state.publisher.register();
this.logger.info(
"PublisherCloudletEvaluate initialized successfully.");
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"PublisherCloudletEvaluate was destroyed successfully.");
// state.publisher = null;
//arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> publishSucceeded(final TradeStateIntContext context,
final GenericCallbackCompletionArguments<Void> arguments) {
this.logger.info(
"PublisherCloudletEvaluate publish successfully.");
//System.out.println("\n\nPublisherCloudletEvaluate OK\n\n");
// state.publisher.unregister();
return ICallback.SUCCESS;
}
}
*/
//QuequeSLAStore (Publisher)
public static final class AmqpPublisherCallbackSlaStore
extends
DefaultAmqpPublisherConnectorCallback<TradeStateIntContext, String, Void> {
/*@Override
public void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletSLAStore registered successfully.");
}*/
/*@Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletSLAStore unregistered successfully.");
// if unregistered as publisher is successful then destroy resource
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
//cloudlet.destroyResource(state.publisher, this);
}*/
@Override
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// if resource initialized successfully then just register as a
// publisher
//state.publisherslastore.register();
this.logger.info(
"PublisherSlaStore initialized successfully.");
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"PublisherCloudletSLAStore was destroyed successfully.");
//state.publisherslastore = null;
//arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> publishSucceeded(final TradeStateIntContext context,
final GenericCallbackCompletionArguments<Void> arguments) {
this.logger.info(
"PublisherCloudletSLAStore publish successfully.");
//System.out.println("\n\nPublisherCloudletSLAStore OK\n\n");
// state.publisherslastore.unregister();
return ICallback.SUCCESS;
}
}
//QuequeCAgw (Publisher)
public static final class AmqpPublisherCallbackCAgw
extends
DefaultAmqpPublisherConnectorCallback<TradeStateIntContext, String, Void> {
/*@Override
public void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletCAgw registered successfully.");
}*/
/*@Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"PublisherCloudletCAgw unregistered successfully.");
// if unregistered as publisher is successful then destroy resource
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
//cloudlet.destroyResource(state.publisher, this);
}*/
@Override
public CallbackCompletion<Void> initializeSucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
// if resource initialized successfully then just register as a
// publisher
//state.publishercagw.register();
this.logger.info(
"PublisherCAgw initialized successfully.");
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"PublisherCloudletCAgw was destroyed successfully.");
//state.publishercagw = null;
//arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
@Override
public CallbackCompletion<Void> publishSucceeded(final TradeStateIntContext context,
final GenericCallbackCompletionArguments<Void> arguments) {
this.logger.info(
"PublisherCloudletCAgw publish successfully.");
//System.out.println("\n\nPublisherCloudletCAgw OK\n\n");
// state.publishercagw.unregister();
return ICallback.SUCCESS;
}
}
public static final class CFP{
public Vector<String> ris =new Vector <String>(40);
public Vector<String> Genera(String x)
{
/* Rimosso quando tutto funzionava per inserire il vero file xml(Agreement)
String v1="file_XML2";
String v2="file_XML3";
ris.add(0, v1);
ris.add(1, v2);
return ris;
*/
/*String t1="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name> Test </ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider></ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId> t1 </ws:TemplateId>\n"
+"\t\t<ws:TemplateName> Client Compute Template </ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:ServiceDescriptionTerm ws:Name=\"TestingJSONModel\" ws:ServiceName=\"mJADESsim \">\n"
+"\t\t\t\t\t<json>\n"
+"\t\t\t\t\t{numProcesses:np,\n"
+"\t\t\t\t\thosts:[{hostname:compute-0-0,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-2,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-3,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-4,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-5,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-6,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-7,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-11clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-16,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-17,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-18,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-19,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-20,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-21,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-22,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-23,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc}],\n"
+"\t\t\t\t\tmachineFile:[compute-1-16,compute-1-17,compute-1-18,compute-1-19,compute-1-20,compute-1-21,compute-1-22,compute-1-23]}\n"
+"\t\t\t\t\t</json>\n"
+"\t\t\t\t\t<np>\n"
+"\t\t\t\t\t8\n"
+"\t\t\t\t\t</np>\n"
+"\t\t\t\t\t<nc>\n"
+"\t\t\t\t\t1\n"
+"\t\t\t\t\t</nc>\n"
+"\t\t\t\t\t<dim>\n"
+"\t\t\t\t\t100\n"
+"\t\t\t\t\t</dim>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:ServiceProperties ws:ServiceName=\"mJADESsim\">\n"
+"\t\t\t\t<ws:VariableSet>\n"
+"\t\t\t\t\t<ws:Variable ws:Nome=\"Response Time\" ws:Metric:\"Time:Duration\">\n"
+"\t\t\t\t\t</ws:Variable>\n"
+"\t\t\t\t\t<ws:Variable ws:Nome=\"Cost\" ws:Metric:\"Time:Duration\">\n"
+"\t\t\t\t\t</ws:Variable>\n"
+"\t\t\t\t</ws:VariableSet>\n"
+"\t\t\t</ws:ServiceProperties>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Response Time IS_LESS_INCLUSIVE 150000,000ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GraranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Cost IS_LESS_INCLUSIVE 100$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GraranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"</ws:Template>\n";
*/
String t2="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider></ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId></ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Response Time IS_LESS_INCLUSIVE 150000,000ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Cost IS_LESS_INCLUSIVE 100$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n";
String t3="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider></ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId></ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Response Time IS_LESS_INCLUSIVE 150000,000ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Cost IS_LESS_INCLUSIVE 100$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n";
String t4="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider></ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId></ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>ANY</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>ANY</memory>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Response Time IS_LESS_INCLUSIVE 150000,000ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective> Cost IS_LESS_INCLUSIVE 100$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n";
ris.add(0,t2);
ris.add(1,t3);
ris.add(2,t4);
//ris.add(0,t1);
return ris;
}
}
public static final class TradeStateIntContext {
ICloudletController<TradeStateIntContext> cloudlet;
/*IKeyValueAccessor<TradeStateIntState> kvStore; //kvState
IKeyValueAccessor<TradeStateIntState> kvStoresla; //kvState
*/
IKvStoreConnector<String, Void> kvStore; //kvState
IKvStoreConnector<String, Void> kvStoresla; //kvState
/*// KV Aggiunto per l'interfaccia grafica
IKeyValueAccessor<TradeStateIntState> kvStoremhttpgw; //kvStateGrafico
//Fine interfaccia grafica
*/
// KV Aggiunto per l'interfaccia grafica
IKvStoreConnector<String, Void> kvStoremhttpgw; //kvStateGrafico
//Fine interfaccia grafica
/*//kV Aggiunto per xml
IKeyValueAccessor<TradeStateIntState> kvStorexml; //kvStateGraficoxml
//Finr xml
*/
//kV Aggiunto per xml
IKvStoreConnector<String, Void> kvStorexml; //kvStateGraficoxml
//Finr xml
/*AmqpQueuePublisher<TradeStateIntState , String> publisher; //quequeState
AmqpQueuePublisher<TradeStateIntState , String> publisherslastore; //quequeSLAStore
AmqpQueuePublisher<TradeStateIntState , String> publishercagw; //quequeCAgw
AmqpQueueConsumer<TradeStateIntState , String> consumer; //quequeEvaluate
AmqpQueueConsumer<TradeStateIntState , byte[]> consumerslagw; //quequeSLAgw
AmqpQueueConsumer<TradeStateIntState , String> consumerresponce; //quequeResponce
*/
//IAmqpQueuePublisherConnector<String, Void> publisher; //quequeState
IAmqpQueuePublisherConnector<String, Void> publisherslastore; //quequeSLAStore
IAmqpQueuePublisherConnector<String, Void> publishercagw; //quequeCAgw
//IAmqpQueueConsumerConnector<String, Void> consumer; //quequeEvaluate
//****IAmqpQueueConsumerConnector<byte[], Void> consumerslagw; //quequeSLAgw
IAmqpQueueConsumerConnector<byte[], Void> consumerslagw;
IAmqpQueueConsumerConnector<String, Void> consumerresponce; //quequeResponce
Gson gson;
Vector<String> WSAG=new Vector<String>();
Vector<String> CFPs=new Vector<String>();
CFP cfp=new CFP();
//Aggiunto dopo che tutto andava bene
//Inizio
// Ho commentata quella che andava bene ed ho aggiunta l'altra
//String concatenazione=null;
String concatenazione="";
String concatenazioneclaint="";
//Fine
JsonObjectfromString object;
JsonObjectfromStringAction objectaction;
JsonObjectfromStringWSAG objectwsag;
JsonObjectfromStringStato object_1;
//Agginta per l'interfaccia grafica e xml
String Clientbe ="Clientbe";
String Negotiation ="Negotiation";
String CA="CA";
String SubmittedSLA="SubmittedSLA";
String CACFP1="CACFP1";
String CACFP2="CACFP2";
String CACFP3="CACFP3";
String CAProposal="CAProposal";
String ClientProposal="ClientProposal";
String SelectedCAProposal="SelectedCAProposal";
String SelectedClientProposal="SelectedClientProposal";
String app1="";
int step=0;
//Fine grafica
String ca5="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<proposal>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider>onevendor</ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId>onevendor_Mv776M6xFz1U00n6IBveoHbSd8X282h2p4y4</ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>COST IS 40$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n"
+"</proposal>\n";
String cp1="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<proposal>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider>onevendor</ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId>onevendor_Mv776M6xFz1U00n6IBveoHbSd8X282h2p4y4</ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"\t\t\t<ws:ServiceDescriptionTerm ws:Name=\"TestingJSONModel\" ws:ServiceName=\"mJADESsim \">\n"
+"\t\t\t\t\t<json>\n"
+"\t\t\t\t\t{numProcesses:np,\n"
+"\t\t\t\t\thosts:[{hostname:compute-0-0,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-2,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-3,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-4,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-5,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-6,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-7,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-11clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-16,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-17,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-18,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-19,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-20,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-21,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-22,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-23,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc}],\n"
+"\t\t\t\t\tmachineFile:[compute-1-16,compute-1-17,compute-1-18,compute-1-19,compute-1-20,compute-1-21,compute-1-22,compute-1-23]}\n"
+"\t\t\t\t\t</json>\n"
+"\t\t\t\t\t<np>\n"
+"\t\t\t\t\t8\n"
+"\t\t\t\t\t</np>\n"
+"\t\t\t\t\t<nc>\n"
+"\t\t\t\t\t1\n"
+"\t\t\t\t\t</nc>\n"
+"\t\t\t\t\t<dim>\n"
+"\t\t\t\t\t100\n"
+"\t\t\t\t\t</dim>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>Response Time IS 122192,667ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>COST IS 20$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n"
+"</proposal>\n";
String cp2="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<proposal>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider>onevendor</ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId>onevendor_Mv776M6xFz1U00n6IBveoHbSd8X282h2p4y4</ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"\t\t\t<ws:ServiceDescriptionTerm ws:Name=\"TestingJSONModel\" ws:ServiceName=\"mJADESsim \">\n"
+"\t\t\t\t\t<json>\n"
+"\t\t\t\t\t{numProcesses:np,\n"
+"\t\t\t\t\thosts:[{hostname:compute-0-0,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-2,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-3,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-4,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-5,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-6,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-7,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-11clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-16,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-17,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-18,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-19,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-20,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-21,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-22,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-23,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc}],\n"
+"\t\t\t\t\tmachineFile:[compute-1-16,compute-1-17,compute-1-18,compute-1-19,compute-1-20,compute-1-21,compute-1-22,compute-1-23]}\n"
+"\t\t\t\t\t</json>\n"
+"\t\t\t\t\t<np>\n"
+"\t\t\t\t\t8\n"
+"\t\t\t\t\t</np>\n"
+"\t\t\t\t\t<nc>\n"
+"\t\t\t\t\t1\n"
+"\t\t\t\t\t</nc>\n"
+"\t\t\t\t\t<dim>\n"
+"\t\t\t\t\t100\n"
+"\t\t\t\t\t</dim>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>Response Time IS 70376,333ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>COST IS 40$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n"
+"</proposal>\n";
String cp3="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<proposal>\n"
+"<ws:Template ws:TemplateId=\"t1\" xmlns:ws=\"http://schemas.ggf.org/graap/2007/03/ws-agreement\">\n"
+"\t<ws:Name>Test1</ws:Name>\n"
+"\t<ws:Context>\n"
+"\t\t<ws:ServiceProvider>onevendor</ws:ServiceProvider>\n"
+"\t\t<ws:TemplateId>onevendor_Mv776M6xFz1U00n6IBveoHbSd8X282h2p4y4</ws:TemplateId>\n"
+"\t\t<ws:TemplateName></ws:TemplateName>\n"
+"\t</ws:Context>\n"
+"\t<ws:Terms>\n"
+"\t\t<ws:All>\n"
+"\t\t\t<ws:ServiceDescriptionTerm ws:Name=\"TestingJSONModel\" ws:ServiceName=\"mJADESsim \">\n"
+"\t\t\t\t\t<json>\n"
+"\t\t\t\t\t{numProcesses:np,\n"
+"\t\t\t\t\thosts:[{hostname:compute-0-0,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-2,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-3,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-4,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-5,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-6,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-7,clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-0-11clock:2800.51,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-16,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-17,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-18,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-19,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-20,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-21,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-22,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc},\n"
+"\t\t\t\t\t{hostname:compute-1-23,clock:3056.75,flops:2.781E9,memRate:1.6E9,latency:1.0E-4,bandwidth:1.1975E7,numCPUs:nc}],\n"
+"\t\t\t\t\tmachineFile:[compute-1-16,compute-1-17,compute-1-18,compute-1-19,compute-1-20,compute-1-21,compute-1-22,compute-1-23]}\n"
+"\t\t\t\t\t</json>\n"
+"\t\t\t\t\t<np>\n"
+"\t\t\t\t\t8\n"
+"\t\t\t\t\t</np>\n"
+"\t\t\t\t\t<nc>\n"
+"\t\t\t\t\t1\n"
+"\t\t\t\t\t</nc>\n"
+"\t\t\t\t\t<dim>\n"
+"\t\t\t\t\t100\n"
+"\t\t\t\t\t</dim>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"t\t\t<ws:ServiceDescriptionTerm ws:Name=\"SAMPLE REQUEST0\" ws:ServiceName=\"SET VARIABLE\">\n"
+"t\t\t\t<mod:Compute xmlns:mod=\"http://occi-wg.org/model\">\n"
+"\t\t\t\t\t<title>OpenNebula VM</title>\n"
+"\t\t\t\t\t<summary>ANY</summary>\n"
+"\t\t\t\t\t<architecture>x86</architecture>\n"
+"\t\t\t\t\t<cpuCores>1</cpuCores>\n"
+"\t\t\t\t\t<cpuSpeed>ANY</cpuSpeed>\n"
+"\t\t\t\t\t<memory>512</memory>\n"
+"\t\t\t\t\t<price>5</price>\n"
+"\t\t\t\t</mod:Compute>\n"
+"\t\t\t</ws:ServiceDescriptionTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Response Time\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>Response Time IS 52159,667ms </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t\t<ws:GaranteeTerm ws:Name=\"MAX Cost\">\n"
+"\t\t\t\t<ws:ServiceScope>\n"
+"\t\t\t\t\t<ws:ServiceName> mJADESsim </ws:ServiceName>\n"
+"\t\t\t\t</ws:ServiceScope>\n"
+"\t\t\t\t<ws:ServiceLevelObjective>COST IS 80$ </ws:ServiceLevelObjective>\n"
+"\t\t\t</ws:GaranteeTerm>\n"
+"\t\t</ws:All>\n"
+"\t</ws:Terms>\n"
+"\t<ws:CreationConstraints/>\n"
+"</ws:Template>\n"
+"</proposal>\n";
}
}