Tabnine Logo
Instance
Code IndexAdd Tabnine to your IDE (free)

How to use
Instance
in
net.roboconf.core.model.beans

Best Java code snippets using net.roboconf.core.model.beans.Instance (Showing top 20 results out of 315)

origin: roboconf/roboconf-platform

Instance current = toProcess.remove( 0 );
Instance copy = new Instance();
copy.name( current.getName());
copy.component( current.getComponent());
copy.channels.addAll( current.channels );
copy.overriddenExports.putAll( current.overriddenExports );
instanceToDuplicate.put( current, copy );
Instance parent = instanceToDuplicate.get( current.getParent());
if( parent != null )
  insertChild( parent, copy );
toProcess.addAll( current.getChildren());
origin: net.roboconf/roboconf-dm

/**
 * Acknowledges a heart beat.
 * @param scopedInstance a root instance
 */
public void acknowledgeHeartBeat( Instance scopedInstance ) {
  String count = scopedInstance.data.get( MISSED_HEARTBEATS );
  if( count != null
      && Integer.parseInt( count ) > THRESHOLD )
    this.logger.info( "Agent " + InstanceHelpers.computeInstancePath( scopedInstance ) + " is alive and reachable again." );
  // Store the moment the first ACK (without interruption) was received.
  // If we were deploying, store it.
  // If we were in problem, store it.
  // If we were already deployed and started, do NOT override it.
  if( scopedInstance.getStatus() != InstanceStatus.DEPLOYED_STARTED
      || ! scopedInstance.data.containsKey( Instance.RUNNING_FROM ))
    scopedInstance.data.put( Instance.RUNNING_FROM, String.valueOf( new Date().getTime()));
  scopedInstance.setStatus( InstanceStatus.DEPLOYED_STARTED );
  scopedInstance.data.remove( MISSED_HEARTBEATS );
}
origin: net.roboconf/roboconf-messaging-api

/**
 * Constructor.
 * @param applicationName the application name
 * @param instance the changed instance
 */
public MsgNotifInstanceChanged( String applicationName, Instance instance ) {
  super();
  this.instancePath = InstanceHelpers.computeInstancePath( instance );
  this.newImports = instance.getImports();
  this.newStatus = instance.getStatus();
  this.applicationName = applicationName;
}
origin: roboconf/roboconf-platform

/**
 * Inserts a child instance.
 * <p>
 * This method does not check anything.
 * In real implementations, such as in the DM, one should
 * use {@link #tryToInsertChildInstance(AbstractApplication, Instance, Instance)}.
 * </p>
 *
 * @param child a child instance (not null)
 * @param parent a parent instance (not null)
 */
public static void insertChild( Instance parent, Instance child ) {
  child.setParent( parent );
  parent.getChildren().add( child );
}
origin: net.roboconf/roboconf-messaging-api

/**
 * Constructor.
 * @param instance
 */
public MsgCmdAddInstance( Instance instance ) {
  this.parentInstancePath = instance.getParent() == null ? null : InstanceHelpers.computeInstancePath( instance.getParent());
  this.instanceName = instance.getName();
  this.componentName = instance.getComponent() != null ? instance.getComponent().getName() : null;
  this.channels = instance.channels;
  this.data = instance.data;
  this.overridenExports = instance.overriddenExports;
}
origin: roboconf/roboconf-platform

@Test
public void testDuplicateInstance_singleInstance() {
  Instance original = new Instance( "inst" ).channel( "chan" ).component( new Component( "comp" ));
  original.overriddenExports.put( "test", "test" );
  original.overriddenExports.put( "A.port", "8012" );
  original.data.put( "some", "data" );
  original.getImports().put( "facet-name", new ArrayList<Import> ());
  original.setStatus( InstanceStatus.DEPLOYED_STARTED );
  Instance copy = InstanceHelpers.replicateInstance( original );
  Assert.assertEquals( original.getName(), copy.getName());
  Assert.assertEquals( original.channels, copy.channels );
  Assert.assertEquals( original.overriddenExports.size(), copy.overriddenExports.size());
  Assert.assertEquals( "test", copy.overriddenExports.get( "test" ));
  Assert.assertEquals( "8012", copy.overriddenExports.get( "A.port" ));
  Assert.assertEquals( 0, copy.getImports().size());
  Assert.assertEquals( original.getComponent(), copy.getComponent());
  Assert.assertEquals( InstanceStatus.NOT_DEPLOYED, copy.getStatus());
}
origin: roboconf/roboconf-platform

@Test
public void testChain() {
  Instance inst = new Instance().name( "ins" ).status( InstanceStatus.DEPLOYING ).component( null ).parent( null );
  Assert.assertEquals( 0, inst.channels.size());
  Assert.assertEquals( "ins", inst.getName());
  Assert.assertEquals( InstanceStatus.DEPLOYING, inst.getStatus());
  Assert.assertNull( inst.getComponent());
  Assert.assertNull( inst.getParent());
  Assert.assertEquals( 1, inst.channel( "woo" ).channels.size());
  Assert.assertEquals( 2, inst.channel( "yeah" ).channels.size());
  Assert.assertEquals( 2, inst.channel( "woo" ).channels.size());
}
origin: roboconf/roboconf-platform

@Test
public void testHasAllRequiredImports_optional() throws Exception {
  Component clusterNodeComponent = new Component( "cluster" ).installerName( "whatever" );
  clusterNodeComponent.addImportedVariable( new ImportedVariable( "cluster.ip", true, false ));
  clusterNodeComponent.addImportedVariable( new ImportedVariable( "cluster.port", true, false ));
  clusterNodeComponent.addExportedVariable( new ExportedVariable( "cluster.ip", null ));
  clusterNodeComponent.addExportedVariable( new ExportedVariable( "cluster.port", "9007" ));
  Instance i1 = new Instance( "inst 1" ).component( clusterNodeComponent );
  i1.overriddenExports.put( "cluster.ip", "192.168.1.15" );
  i1.setStatus( InstanceStatus.STARTING );
  Instance i2 = new Instance( "inst 2" ).component( clusterNodeComponent );
  i2.overriddenExports.put( "cluster.ip", "192.168.1.28" );
  // The cluster node does not know about the other node
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i1, null ));
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i2, null ));
  // The node is now aware of another node
  ImportHelpers.addImport( i1, "cluster", new Import( i2 ));
  i1.setStatus( InstanceStatus.STARTING );
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i1, null ));
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i2, null ));
  i1.getImports().clear();
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i1, null ));
  Assert.assertTrue( ImportHelpers.hasAllRequiredImports( i2, null ));
}
origin: net.roboconf/roboconf-dm-rest-commons

Instance instance = new Instance();
  instance.setName( n.textValue());
  instance.setStatus( InstanceStatus.whichStatus( n.textValue()));
  instance.setComponent( instanceComponent );
origin: roboconf/roboconf-platform

@Test
public void testInstances() {
  List<Instance> instances = new ArrayList<> ();
  for( int i=0; i<10; i++ ) {
    Instance inst = new Instance( "inst-" + i ).component( new Component( "comp" ));
    instances.add( inst );
  }
  Assert.assertEquals( 0, RuntimeModelValidator.validate( instances ).size());
}
origin: roboconf/roboconf-platform

@Test
public void checkInstanceReplication() {
  TestApplicationTemplate tpl = new TestApplicationTemplate();
  Application app = new Application( tpl );
  Assert.assertEquals( 5, InstanceHelpers.getAllInstances( app ).size());
  Assert.assertEquals( 5, InstanceHelpers.getAllInstances( tpl ).size());
  for( Instance inst : InstanceHelpers.getAllInstances( tpl )) {
    String instancePath = InstanceHelpers.computeInstancePath( inst );
    Instance copiedInstance = InstanceHelpers.findInstanceByPath( app, instancePath );
    Assert.assertNotNull( copiedInstance );
    Assert.assertEquals( inst.getName(), copiedInstance.getName());
    Assert.assertEquals( inst.getComponent(), copiedInstance.getComponent());
    Assert.assertEquals( inst.getImports(), copiedInstance.getImports());
    Assert.assertEquals( inst.getParent(), copiedInstance.getParent());
    Assert.assertEquals( inst.getChildren().size(), copiedInstance.getChildren().size());
    // Paths are the same, so the children are equal (even if they are not the same object)
    Assert.assertEquals( inst.getChildren(), copiedInstance.getChildren());
    Assert.assertEquals( inst.channels, copiedInstance.channels );
    Assert.assertEquals( inst.overriddenExports, copiedInstance.overriddenExports );
    Assert.assertEquals( inst.data, copiedInstance.data );
    Assert.assertFalse( inst == copiedInstance );
  }
}
origin: roboconf/roboconf-platform

@Test
public void testRuntimeData() throws Exception {
  // The graph
  Graphs graphs = new Graphs();
  Component vmComponent = new Component( "vm" ).installerName( Constants.TARGET_INSTALLER );
  graphs.getRootComponents().add( vmComponent );
  // The file to read
  File f = TestUtils.findTestFile( "/configurations/valid/single-runtime-instance.instances" );
  FromInstanceDefinition fromDef = new FromInstanceDefinition( f.getParentFile());
  Collection<Instance> rootInstances = fromDef.buildInstances( graphs, f );
  Assert.assertEquals( 0, fromDef.getErrors().size());
  // The assertions
  Assert.assertEquals( 1, rootInstances.size());
  Instance instance = rootInstances.iterator().next();
  Assert.assertEquals( "vm 1", instance.getName());
  Assert.assertEquals( vmComponent, instance.getComponent());
  Assert.assertEquals( InstanceStatus.DEPLOYED_STARTED, instance.getStatus());
  Assert.assertEquals( 3, instance.data.size());
  Assert.assertEquals( "127.0.0.1", instance.data.get( "ip" ));
  Assert.assertEquals( "mach-ID", instance.data.get( "machine-id" ));
  Assert.assertEquals( "something different", instance.data.get( "whatever" ));
}
origin: net.roboconf/roboconf-agent

@Override
public void start( Instance instance ) throws PluginException {
  String name = instance != null ? instance.getName() : null;
  this.logger.info( this.agentId + " is starting instance " + name + "." );
  this.currentState = InstanceStatus.DEPLOYED_STARTED;
}
origin: roboconf/roboconf-platform

/**
 * Determines whether an instances is associated with the "target" installer or not.
 * @param instance an instance (not null)
 * @return true if it is associated with the "target" installer, false otherwise
 */
public static boolean isTarget( Instance instance ) {
  return instance.getComponent() != null
      && ComponentHelpers.isTarget( instance.getComponent());
}
origin: net.roboconf/roboconf-agent

if( instance.getStatus() != InstanceStatus.NOT_DEPLOYED ) {
  this.logger.fine( instancePath + " cannot be deployed. Prerequisite status: NOT_DEPLOYED (but was " + instance.getStatus() + ")." );
} else if( instance.getParent() != null
    && instance.getParent().getStatus() != InstanceStatus.DEPLOYED_STARTED
    && instance.getParent().getStatus() != InstanceStatus.DEPLOYED_STOPPED
    && instance.getParent().getStatus() != InstanceStatus.UNRESOLVED
    && instance.getParent().getStatus() != InstanceStatus.WAITING_FOR_ANCESTOR ) {
  this.logger.fine( instancePath + " cannot be deployed because its parent is not deployed. Parent status: " + instance.getParent().getStatus() + "." );
  instance.setStatus( InstanceStatus.DEPLOYING );
  try {
    this.messagingClient.sendMessageToTheDm( new MsgNotifInstanceChanged( this.appName, instance ));
    instance.setStatus( InstanceStatus.DEPLOYED_STOPPED );
    this.messagingClient.sendMessageToTheDm( new MsgNotifInstanceChanged( this.appName, instance ));
    Utils.logException( this.logger, e );
    instance.setStatus( InstanceStatus.NOT_DEPLOYED );
    this.messagingClient.sendMessageToTheDm( new MsgNotifInstanceChanged( this.appName, instance ));
origin: net.roboconf/roboconf-dm

  @Override
  public void execute() throws CommandException {

    // Resolve runtime structure
    Instance rootInstance = resolveInstance( this.instr, this.instr.getReplicatedInstancePath(), true );
    ManagedApplication ma = resolveManagedApplication( this.manager, this.instr );

    // Verify we can create new VMs in the model
    CreateInstanceCommandExecution.verify( this.executionContext, rootInstance.getComponent());

    try {
      // Copy the instance
      Instance copy = InstanceHelpers.replicateInstance( rootInstance );
      copy.setName( this.instr.getNewInstanceName());
      this.manager.instancesMngr().addInstance( ma, null, copy );

      // Associate this new instance with the same target, if it has one
      String targetId = this.manager.targetsMngr().findTargetId( ma.getApplication(), "/" + rootInstance.getName(), true );
      if( targetId != null )
        this.manager.targetsMngr().associateTargetWith( targetId, ma.getApplication(), "/" + copy.getName());

      // Register meta-data
      CreateInstanceCommandExecution.update( this.executionContext, copy );

    } catch( Exception e ) {
      throw new CommandException( e );
    }
  }
}
origin: roboconf/roboconf-platform

/**
 * Determines whether an instance name is not already used by a sibling instance.
 * @param application the application (not null)
 * @param parentInstance the parent instance (can be null to indicate a root instance)
 * @param nameToSearch the name to search
 * @return true if a child instance of <code>parentInstance</code> has the same name, false otherwise
 */
public static boolean hasChildWithThisName( AbstractApplication application, Instance parentInstance, String nameToSearch ) {
  boolean hasAlreadyAChildWithThisName = false;
  Collection<Instance> list = parentInstance == null ? application.getRootInstances() : parentInstance.getChildren();
  for( Iterator<Instance> it = list.iterator(); it.hasNext() && ! hasAlreadyAChildWithThisName; ) {
    hasAlreadyAChildWithThisName = Objects.equals( nameToSearch, it.next().getName());
  }
  return hasAlreadyAChildWithThisName;
}
origin: roboconf/roboconf-platform

@Test
public void testComponentResolutionWhenSurroundingSpaces() throws Exception {
  Component vmComponent = new Component( "VM" ).installerName( "target" );
  Component aComponent = new Component( "A" ).installerName( "whatever" );
  vmComponent.addChild( aComponent );
  Graphs graphs = new Graphs();
  graphs.getRootComponents().add( vmComponent );
  File f = TestUtils.findTestFile( "/configurations/valid/instance-with-space-after.instances" );
  FromInstanceDefinition fromDef = new FromInstanceDefinition( f.getParentFile());
  Collection<Instance> rootInstances = fromDef.buildInstances( graphs, f );
  Iterator<ParsingError> iterator = fromDef.getErrors().iterator();
  Assert.assertFalse( iterator.hasNext());
  Assert.assertEquals( 2, rootInstances.size());
  for( Instance rootInstance : rootInstances ) {
    Assert.assertEquals( 1, rootInstance.getChildren().size());
    Instance instance = rootInstance.getChildren().iterator().next();
    Assert.assertEquals( "A", instance.getComponent().getName());
    Assert.assertEquals( "A ", instance.getName());
  }
}
origin: net.roboconf/roboconf-dm

InstanceStatus oldstatus = i.getStatus();
i.setStatus( InstanceStatus.NOT_DEPLOYED );
i.getImports().clear();
origin: roboconf/roboconf-platform

@Test
public void testMessage_addInstance() throws Exception {
  Instance child = new Instance( "child" ).channel( "channel 4" ).status( InstanceStatus.DEPLOYED_STOPPED );
  child.component( new Component( "comp_child" ).installerName( "whatever" ));
  MsgCmdAddInstance msg = new MsgCmdAddInstance( child );
  checkBasics( msg, MsgCmdAddInstance.class );
  Instance root = new Instance( "root" ).status( InstanceStatus.DEPLOYED_STARTED ).channel( "channel1" ).channel( "channel2" );
  root.component( new Component( "comp_root" ).installerName( "whatever" ));
  InstanceHelpers.insertChild( root, child );
  msg = new MsgCmdAddInstance( child );
  checkBasics( msg, MsgCmdAddInstance.class );
  msg = new MsgCmdAddInstance( new Instance( "instance without component" ));
  checkBasics( msg, MsgCmdAddInstance.class );
}
net.roboconf.core.model.beansInstance

Javadoc

An instance object represents a running component instance.

Most used methods

  • getName
  • getComponent
  • getStatus
  • <init>
  • getImports
  • setStatus
  • component
  • getParent
  • getChildren
  • setName
  • setComponent
  • channel
    Adds a channel in a chain approach.
  • setComponent,
  • channel,
  • name,
  • setParent,
  • status,
  • equals,
  • parent,
  • toString

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now