Package eu.mosaic_cloud.benchmarks

Source Code of eu.mosaic_cloud.benchmarks.ClientParametirezedCloudlet$ClientParametirezedCloudletContext

//###
//# #%L
//# mosaic-java-benchmarks
//# %%
//# Copyright (C) 2010 - 2012 Seconda Università di Napoli
//#Authors: Massimiliano Rak, Giuseppe Aversano
//# %%
//# 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.benchmarks;



import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueuePublisherConnector;
import eu.mosaic_cloud.cloudlets.connectors.queue.amqp.IAmqpQueuePublisherConnectorFactory;
import eu.mosaic_cloud.cloudlets.core.CallbackArguments;
import eu.mosaic_cloud.cloudlets.core.CloudletCallbackArguments;
import eu.mosaic_cloud.cloudlets.core.CloudletCallbackCompletionArguments;
import eu.mosaic_cloud.cloudlets.core.GenericCallbackCompletionArguments;
import eu.mosaic_cloud.cloudlets.core.ICallback;
import eu.mosaic_cloud.cloudlets.core.ICloudletController;
import eu.mosaic_cloud.cloudlets.tools.DefaultAmqpPublisherConnectorCallback;
import eu.mosaic_cloud.cloudlets.tools.DefaultCloudletCallback;
import eu.mosaic_cloud.platform.core.configuration.ConfigurationIdentifier;
import eu.mosaic_cloud.platform.core.configuration.IConfiguration;
import eu.mosaic_cloud.platform.core.utils.PlainTextDataEncoder;
import eu.mosaic_cloud.tools.callbacks.core.CallbackCompletion;


public class ClientParametirezedCloudlet
{
  public static final class AmqpPublisherCallback
      extends DefaultAmqpPublisherConnectorCallback<ClientParametirezedCloudletContext, String, Void>
  {
    @Override
    public CallbackCompletion<Void> destroySucceeded (final ClientParametirezedCloudletContext context, final CallbackArguments arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet publisher destroyed successfully.");
      return ICallback.SUCCESS;
    }
   
    @Override
    public CallbackCompletion<Void> initializeSucceeded (final ClientParametirezedCloudletContext context, final CallbackArguments arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet publisher initialized successfully.");
      this.logger.info ("ClientParametirezedCloudlet publisher messager successfully.");
     
      this.logger.info("\n\n{'type':'Ready','id':'2','parameters':['2','4']}\n\n"); //[dim,np]
      this.logger.info("\n\n{'type':'Start','id':'2','parameters':['2','4']}\n\n"); //[dim,np]
      this.logger.info("\n\n{'type':'Check','id':'2','parameters':['2','4']}\n\n"); //[dim,np]
      this.logger.info("\n\n{'type':'Stop','id':'2','parameters':['2','4']}\n\n")//[dim,np]
      this.logger.info("\n\n{'type':'Ready','id':'2','parameters':['2','4']}\n\n"); //[dim,np]
      this.logger.info("\n\n{'type':'Start','id':'2','parameters':['2','4']}\n\n"); //[dim,np]
      this.logger.info("\n\n{'type':'Stop','id':'2','parameters':['2','4']}\n\n")//[dim,np]
      this.logger.info("\n\n{'type':'Plot','id':'2'}\n\n");
      this.logger.info("\n\n{'type':'Ready','id':'2','parameters':['2,'4']}\n\n"); //[dim]
     
     
     
        context.publisher.publish("{'type':'Ready','id':'2','parameters':['2','4']}", null); //[dim,np]
       
        try {
        Thread.sleep(20000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Start','id':'2','parameters':['2','4']}", null); //[dim,np]
       
        try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Check','id':'2','parameters':['2','4']}", null); //[dim,np]
        try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Stop','id':'2','parameters':['2','4']}", null); //[dim,np]
        try {
        Thread.sleep(20000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     
       
        context.publisher.publish("{'type':'Plot','id':'2'}", null);
       
        try {
        Thread.sleep(20000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Ready','id':'2','parameters':['2','4']}", null); //[dim,np]
       
        try {
        Thread.sleep(20000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Start','id':'2','parameters':['2','4']}", null); //[dim,np]
        try {
        Thread.sleep(60000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Stop','id':'2','parameters':['2','4']}", null); //[dim,np]
        try {
        Thread.sleep(30000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Plot','id':'2'}", null);
       
        try {
        Thread.sleep(20000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }     

        context.publisher.publish("{'type':'Ready','id':'2','parameters':['2','4']}", null); //[dim,np]
       
   
   
   
     
      return ICallback.SUCCESS;
    }
   
    @Override
    public CallbackCompletion<Void> publishSucceeded (final ClientParametirezedCloudletContext context, final GenericCallbackCompletionArguments<Void> arguments)
    {
      //context.cloudlet.destroy ();
      this.logger.info ("ClientParametirezedCloudlet publisher successfully.");
      return ICallback.SUCCESS;
    }
  }
 
  public static final class LifeCycleHandler
      extends DefaultCloudletCallback<ClientParametirezedCloudletContext>
  {
    @Override
    public CallbackCompletion<Void> destroy (final ClientParametirezedCloudletContext context, final CloudletCallbackArguments<ClientParametirezedCloudletContext> arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet is being destroyed...");
      return context.publisher.destroy ();
    }
   
    @Override
    public CallbackCompletion<Void> destroySucceeded (final ClientParametirezedCloudletContext context, final CloudletCallbackCompletionArguments<ClientParametirezedCloudletContext> arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet was destroyed successfully.");
      return ICallback.SUCCESS;
    }
   
    @Override
    public CallbackCompletion<Void> initialize (final ClientParametirezedCloudletContext context, final CloudletCallbackArguments<ClientParametirezedCloudletContext> arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet initializing...");
      context.cloudlet = arguments.getCloudlet ();
      final IConfiguration configuration = context.cloudlet.getConfiguration ();
      final IConfiguration queueConfiguration = configuration.spliceConfiguration (ConfigurationIdentifier.resolveAbsolute ("queueclient.publisher"));
      context.publisher = context.cloudlet.getConnectorFactory (IAmqpQueuePublisherConnectorFactory.class).create (queueConfiguration, String.class, PlainTextDataEncoder.DEFAULT_INSTANCE, new AmqpPublisherCallback (), context);
      return context.publisher.initialize ();
    }
   
    @Override
    public CallbackCompletion<Void> initializeSucceeded (final ClientParametirezedCloudletContext context, final CloudletCallbackCompletionArguments<ClientParametirezedCloudletContext> arguments)
    {
      this.logger.info ("ClientParametirezedCloudlet initialized successfully.");
     
      return ICallback.SUCCESS;
    }
  }
 
  public static final class ClientParametirezedCloudletContext
  {
    ICloudletController<ClientParametirezedCloudletContext> cloudlet;
    IAmqpQueuePublisherConnector<String, Void> publisher;
  }
}
TOP

Related Classes of eu.mosaic_cloud.benchmarks.ClientParametirezedCloudlet$ClientParametirezedCloudletContext

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.