//###
//# #%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.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 TradeStateInt {
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.");
/* ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
IConfiguration configuration = cloudlet.getConfiguration();
IConfiguration configuration2 = cloudlet.getConfiguration();
IConfiguration configuration3 = cloudlet.getConfiguration();
IConfiguration configuration4 = cloudlet.getConfiguration();
IConfiguration configuration5 = cloudlet.getConfiguration();
IConfiguration configuration6 = cloudlet.getConfiguration();
DataEncoder<String> encoder = new PojoDataEncoder<String>(
String.class);
DataEncoder<byte[]> nonencoder = new NopDataEncoder();*/
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);
/*state.consumer = new AmqpQueueConsumer<TradeStateInt.TradeStateIntState,String>(
queueConfiguration, cloudlet, String.class, encoder);*/
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);
/*state.publisher = new AmqpQueuePublisher<TradeStateInt.TradeStateIntState,String>(
queueConfigurationb, cloudlet, String.class, encoder);*/
final IConfiguration queueConfiguration3 = configuration3
.spliceConfiguration(ConfigurationIdentifier
.resolveAbsolute("queueinter"));
context.consumerslagw = context.cloudlet.getConnectorFactory
(IAmqpQueueConsumerConnectorFactory.class).create
(queueConfiguration3, byte[].class, NullDataEncoder.create(),
new AmqpConsumerCallbackSLAgw (), context);
/*state.consumerslagw = new AmqpQueueConsumer<TradeStateInt.TradeStateIntState,byte[]>(
queueConfiguration3, cloudlet, null, nonencoder);*/
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);
/*state.consumerresponce = new AmqpQueueConsumer<TradeStateInt.TradeStateIntState,String>(
queueConfiguration4, cloudlet, String.class, encoder);*/
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);
/*state.publisherslastore = new AmqpQueuePublisher<TradeStateInt.TradeStateIntState,String>(
queueConfigurationb5, cloudlet, String.class, encoder);*/
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);
/*state.publishercagw = new AmqpQueuePublisher<TradeStateInt.TradeStateIntState,String>(
queueConfigurationb6, cloudlet, String.class, encoder);*/
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);
/*state.kvStore = new KeyValueAccessor<TradeStateIntState>(
kvConfiguration, cloudlet, new JsonDataEncoder<String>(
String.class));*/
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);
/*state.kvStoresla = new KeyValueAccessor<TradeStateIntState>(
kvConfiguration2, cloudlet, new JsonDataEncoder<String>(
String.class));*/
// 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);
/*state.kvStoremhttpgw = new KeyValueAccessor<TradeStateIntState>(
kvConfiguration3, cloudlet, new JsonDataEncoder<String>(
String.class));*/
//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, byte[].class, NullDataEncoder.create (),
new KeyValueCallbackxml (), context);
/* state.kvStorexml = new KeyValueAccessor<TradeStateIntState>(
kvConfiguration4, cloudlet,nonencoder);*/
//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.consumer.initialize(),context.publisher.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.");
/*ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
cloudlet.initializeResource(state.kvStore, new KeyValueCallbackstatostore(),
state);
cloudlet.initializeResource(state.kvStoresla, new KeyValueCallbackslastore(),
state);
// kvStore Aggiunto per l'interfaccia grafica
cloudlet.initializeResource(state.kvStoremhttpgw, new KeyValueCallbackmhttpgw(),
state);
//Fine kv grafico
// kvStore Aggiunto per xml grafica
cloudlet.initializeResource(state.kvStorexml, new KeyValueCallbackxml(),
state);
//Fine kv xml
cloudlet.initializeResource(state.consumer,
new AmqpConsumerCallbackState(), state);
cloudlet.initializeResource(state.publisher,
new AmqpPublisherCallbackEvaluate(), state);
cloudlet.initializeResource(state.consumerslagw,
new AmqpConsumerCallbackSLAgw(), state);
cloudlet.initializeResource(state.consumerresponce,
new AmqpConsumerCallbackResponce(), state);
cloudlet.initializeResource(state.publishercagw,
new AmqpPublisherCallbackCAgw(), state);
cloudlet.initializeResource(state.publisherslastore,
new AmqpPublisherCallbackSlaStore(), state);*/
//context.cloudlet = arguments.getCloudlet ();
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.publisher.destroy(),context.publishercagw.destroy(),context.publisherslastore.destroy(),context.consumer.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) {
//System.out.println("\n\nSetSucceeded KVState\n\n");
this.logger.info("SetSucceeded KVState");
String k=arguments.getKey();
//System.out.println("\n\nKEY:"+k);
this.logger.info("KEY: "+k);
//System.out.println("\n\n");
String sta=(String)arguments.getValue();
//System.out.println("\n\nStato:"+sta);
this.logger.info("Stato: "+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 CloudletTradeState Delete succeeded\n\n ");
return ICallback.SUCCESS;
}
public CallbackCompletion<Void> getSucceeded(final TradeStateIntContext context,
final KvStoreCallbackCompletionArguments<String, Void> arguments) {
this.logger.info("GetSucceeded KVState da parte di TRADESTATE");
//System.out.println("\n\nGetSucceeded KVState da parte di TRADESTATE\n\n");
String k=arguments.getKey();
this.logger.info("KEY "+k);
//System.out.println("\n\nKEY:"+k);
//System.out.println("\n\n");
///this.logger.info("STAMPA DI arguments.getValue(): "+arguments.getValue());
String p=null;
if (arguments.getValue()==null){
p=new String("");}
else {
p=new String(arguments.getValue());}
this.logger.info("STATO "+p);
//System.out.println("\n\nSTATO:"+p);
//System.out.println("\n\n");
int pos = Integer.parseInt(k);
String vall=context.WSAG.get(pos);
//System.out.println("\n\nMessaggio Ricevuto nel Get da TRADESTATE:"+vall);
this.logger.info("Messaggio Ricevuto nel Get da TRADESTATE:"+vall);
context.objectwsag=context.gson.fromJson(vall,JsonObjectfromStringWSAG.class);
this.logger.info("Type2 "+context.objectwsag.getType());
if((context.objectwsag.getType().equals("Submit")) && (p.equals(""))){
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);
//Aggiunta per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Submit','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'SubmitCFP','Action':'','StateNegotiation':'null','SendCA':''}", null);
//Fine interfaccia grafica
//System.out.println("\nTradeState Push Submit a SLASTORE\n");
this.logger.info("TradeState Push Submit a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//rimosso dopo fatto prova prof.
//state.publisherslastore.publish(vall, null, "text/plain");
//System.out.println("\nTradeState Push SLAPOLICY:\n");
this.logger.info("TradeState Push SLAPOLICY:");
this.logger.info("{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'submitCFP','rules':['Parametri','Expression','Action']}");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'submitCFP','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'submitCFP','rules':['Parametri','Expression','Action']}", null);
}
//Aggiunto dopo che tutto funzionava bene
//Aggiungo l'if per il cotrollo del wsag
//Inizio(SOLO l' if(state.objectwsag.getWSAG().contains(state.concatenazione)) è stato aggiunto il contenuto deve cmq restare )
//Rimosso per la demo
// if(state.concatenazione.contains(state.objectwsag.getWSAG())){
//if(true){
if((context.objectwsag.getType().equals("Submit")) && (p.equals("OptionsAvailable"))){
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.ca5.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);
//Aggiunta per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Submit','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'SubmitProposal','Action':'','StateNegotiation':'OptionsAvailable','SendCA':''}", null);
//Fine interfaccia grafica
//System.out.println("\nTradeState Push Submit a SLASTORE\n");
this.logger.info("TradeState Push Submit a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//rimosso dopo che il prof ha fatto le prove
//state.publisherslastore.publish(vall, null, "text/plain");
//System.out.println("\nTradeState Push SLAPOLICY:\n");
this.logger.info("TradeState Push SLAPOLICY");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'submitProposal','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'submitProposal','rules':['Parametri','Expression','Action']}", null);
}
if((context.objectwsag.getType().equals("Sign")) && (p.equals("Reserved"))){
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);
//Aggiunta per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Sign','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'Sign','Action':'','StateNegotiation':'Reserved','SendCA':''}", null);
//Fine interfaccia grafica
//System.out.println("\nTradeState Push Sign a SLASTORE\n");
this.logger.info("TradeState Push Sign a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//rimosso dopo che il prof ha fatto le prove
//state.publisherslastore.publish(vall, null, "text/plain");
//System.out.println("\nTradeState Push SLAPOLICY:\n");
this.logger.info("TradeState Push SLAPOLICY");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'sign','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'sign','rules':['Parametri','Expression','Action']}", null);
}
if((context.objectwsag.getType().equals("Terminate")) && (p.equals("Signed"))){
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);
//Aggiunta per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Clientbe,"{'RequestClient':'Terminate','StateWS':''}", null);
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'Terminate','Action':'','StateNegotiation':'Signed','SendCA':''}", null);
//Fine interfaccia grafica
//System.out.println("\nTradeState Push Terminate a SLASTORE\n");
this.logger.info("TradeState Push Terminate a SLASTORE");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//rimosso dopo che il prof ha fatto le prove
//state.publisherslastore.publish(vall, null, "text/plain");
//System.out.println("\nTradeState Push SLAPOLICY:\n");
this.logger.info("TradeState Push SLAPOLICY:");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'Terminate','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"','action':'Terminate','rules':['Parametri','Expression','Action']}", 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, byte[], 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.");
//state.consumer.register();
return ICallback.SUCCESS;
}
/* @Override
public void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletState registered successfully.");
}*/
/* @Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletState unregistered successfully.");
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
// cloudlet.destroyResource(state.consumer, this);
}*/
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletState was destroyed successfully.");
// state.consumer = null;
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
/*@Override
public void acknowledgeSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"acknowledgeSucceeded");
//state.consumer.unregister();
}*/
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<String> arguments){
/*AmqpQueueConsumeMessage<String> message = arguments.getMessage();
String data = message.getData();*/
final String data = arguments.getMessage ();
this.logger.info(
"ConsumerCloudletState received message from SLAPolicy "
+ data);
//System.out.println("\n\nMessage Ricevuto da SLAPolicy:"+data);
//System.out.println("\n");
this.logger.info("Message Ricevuto da SLAPolicy:"+data);
context.objectaction=context.gson.fromJson(data,JsonObjectfromStringAction.class);
//System.out.println("\nAzione da intraprendere:"+context.objectaction.getAction());
//System.out.println("\n");
this.logger.info("Azione da intraprendere: "+context.objectaction.getAction());
//System.out.println("\nWSAG:"+context.objectaction.getWSAG());
//System.out.println("\n");
this.logger.info("WSAG:"+context.objectaction.getWSAG());
//System.out.println("\nID e Nuovo Stato:"+context.objectaction.getId()+","+context.objectaction.getNewState());
//System.out.println("\n");
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
}
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 void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletSLAgw registered successfully.");
}*/
/*@Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletSLAgw unregistered successfully.");
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
// cloudlet.destroyResource(state.consumerslagw, this);
}*/
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletSLAgw was destroyed successfully.");
// state.consumerslagw = null;
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
/*@Override
public void acknowledgeSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"acknowledgeSucceeded");
//state.consumerslagw.unregister();
}*/
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<byte[]> arguments){
// TODO come gestisco il vettore di byte????
/* AmqpQueueConsumeMessage<byte[]> message = arguments.getMessage();
byte[] val = message.getData();
String data = new String(val);*/ //??????? come gestisco il vettore di byte????
//*****byte[] val= arguments.getMessage ();
//*****String data = new String(val);
//*****final String data =new String(arguments.getMessage().toString());
String data=new String(arguments.getMessage());
//final String data = arguments.getMessage ();
this.logger.info(
"ConsumerCloudletSLAgw received message from SLAgw: "
+ data);
//System.out.println("\n\nMessage Ricevuto da SLAgw:"+data);
this.logger.info("Message Ricevuto da SLAgw");
//System.out.println("\n");
context.objectwsag=context.gson.fromJson(data,JsonObjectfromStringWSAG.class);
this.logger.info("TYPE "+context.objectwsag.getType());
if(context.objectwsag.getType().equals("Check")){
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);
//System.out.println("\nTradeState Push Check a SLASTORE\n");
context.publisherslastore.publish("{'type':'"+context.objectwsag.getType()+"','id':'"+context.objectwsag.getId()+"','wsag':'"+context.objectwsag.getWSAG()+"'}",null);
//rimosso dopo che il prof ha fatto le prove
//state.publisherslastore.publish(data, null, "text/plain");
}
else
{
this.logger.info("ID "+context.objectwsag.getId());
context.WSAG.add(Integer.parseInt(context.objectwsag.getId()),data);
this.logger.info("PARSEINT "+Integer.parseInt(context.objectwsag.getId()));
context.kvStore.get(context.objectwsag.getId(),null);
}
context.consumerslagw.acknowledge (arguments.getToken ());
//message.acknowledge();
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.");
//state.consumerresponce.register();
return ICallback.SUCCESS;
}
/*@Override
public void registerSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletResponce registered successfully.");
}*/
/*@Override
public void unregisterSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"ConsumerCloudletResponce unregistered successfully.");
ICloudletController<TradeStateIntState > cloudlet = arguments
.getCloudlet();
// cloudlet.destroyResource(state.consumerresponce, this);
}*/
@Override
public CallbackCompletion<Void> destroySucceeded(final TradeStateIntContext context,
final CallbackArguments arguments) {
this.logger.info(
"ConsumerCloudletResponce was destroyed successfully.");
// state.consumerresponce = null;
// arguments.getCloudlet().destroy();
return ICallback.SUCCESS;
}
/*@Override
public void acknowledgeSucceeded(TradeStateIntState state,
CallbackArguments<TradeStateIntState > arguments) {
this.logger.info(
"acknowledgeSucceeded");
//state.consumerresponce.unregister();
}*/
public CallbackCompletion<Void> consume(final TradeStateIntContext context, final AmqpQueueConsumeCallbackArguments<String> arguments){
/*AmqpQueueConsumeMessage<String> message = arguments.getMessage();
String data = message.getData();*/
final String data = arguments.getMessage ();
this.logger.info(
"ConsumerCloudletResponce received message from CAgw "
+ data);
//System.out.println("\n\nMessage Ricevuto dalla CAgw:"+data);
this.logger.info("Message Ricevuto dalla CAgw:");
//System.out.println("\n");
context.objectaction=context.gson.fromJson(data,JsonObjectfromStringAction.class);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(context.objectaction.getAction().equals("CAresponse")){
//System.out.println("\nTRADESTATE push SLAPolicy:\n");
//System.out.println("\n{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAresponse','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAresponse','rules':['Parametri','Expression','Action']}", null);
//Aggiunto dopo che tutto andava bene
//Inizio
// Ho commentata quella che andava bene ed ho aggiunta l'altra
// state.concatenazione=state.concatenazione+state.objectaction.getWSAG();
context.concatenazione=context.concatenazione+"\n\n"+context.objectaction.getWSAG();
context.step++;
if (context.step==1){
context.concatenazioneclaint=context.concatenazioneclaint+"\n\n"+context.cp1;
}
if (context.step==2){
context.concatenazioneclaint=context.concatenazioneclaint+"\n\n"+context.cp2;
}
if (context.step==3){
context.concatenazioneclaint=context.concatenazioneclaint+"\n\n"+context.cp3;
}
//Fine
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);
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAresponse','Action':'','StateNegotiation':'Evaluating','SendCA':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAresponse'}" , null);
//Fine interfaccia grafica
//System.out.println("\nConcatenazione:"+context.concatenazione+"\n");
// System.out.println("\nTRADASTATE GET KV di SLASTORE\n");
context.kvStoresla.get(context.objectaction.getId(),null);
}
if(context.objectaction.getAction().equals("CAreserve")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAreserve','Action':'','StateNegotiation':'Reserving','SendCA':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAreserve'}" , 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':'CAreserve','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAreserve','rules':['Parametri','Expression','Action']}", null);
}
if(context.objectaction.getAction().equals("CAsigned")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAsigned','Action':'','StateNegotiation':'Signing','SendCA':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAsigned'}" , 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':'CAsigned','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAsigned','rules':['Parametri','Expression','Action']}", null);
}
if(context.objectaction.getAction().equals("CAterminated")){
//Aggiunto per l'interfaccia grafica
context.kvStoremhttpgw.set(context.Negotiation,"{'SendSLAPolicy':'CAterminated','Action':'','StateNegotiation':'Terminating','SendCA':''}", null);
context.kvStoremhttpgw.set(context.CA,"{'ResponseCA':'CAterminated'}" , 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':'CAterminated','rules':['Parametri','Expression','Action']}\n");
context.publisher.publish("{'type':'Evaluate','id':'"+context.objectaction.getId()+"','wsag':'"+context.objectaction.getWSAG()+"','action':'CAterminated','rules':['Parametri','Expression','Action']}", 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','Action':'','StateNegotiation':'Evaluating','SendCA':''}", 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,"{'SendSLAPolicy':'CArefused','Action':'','StateNegotiation':'','SendCA':''}", 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<byte[], 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";
}
}