Interface ProcessingUnit

All Superinterfaces:
AdminAware, Iterable<ProcessingUnitInstance>, StatisticsMonitor
All Known Subinterfaces:
InternalProcessingUnit
All Known Implementing Classes:
DefaultProcessingUnit

public interface ProcessingUnit extends Iterable<ProcessingUnitInstance>, AdminAware, StatisticsMonitor
A processing unit holds one or more ProcessingUnitInstances.
Author:
kimchy, itaif
  • Method Details

    • getProcessingUnits

      ProcessingUnits getProcessingUnits()
      Returns:
      Returns the handle to all the different processing units.
    • getName

      String getName()
      Returns:
      Returns the name of the processing unit.
    • getNumberOfInstances

      @Deprecated int getNumberOfInstances()
      Deprecated.
      - since 9.5.0 - please use the following alternatives: For retrieving planned number of partitions use getPlannedNumberOfPartitions(). Otherwise use getPlannedNumberOfInstances() for retrieving planned number of stateful (primary+backup Space instances) -or- stateless pu instances.

      Note that this method does not count the number of running instances, but rather the number of planned instances for the processing unit. To count the number of currently discovered running processing unit instances use the method getInstances().

      Returns:
      Returns the number of required instances as defined in the processing unit's SLA. If there are backups, it will only return the number of primary instances and not the number of backup.
    • getPlannedNumberOfPartitions

      int getPlannedNumberOfPartitions()
      For stateful processing unit (primary+backup Space) will return the planned partition count - i.e. the number of planned primary instances (excluding backups). If called for a stateless processing unit, will return the planned number of instances.

      Note that this method does not count the number of running instances, but rather the number of planned primary instances for the processing unit. To count the number of currently discovered running processing unit partitions use the method getPartitions().

      Returns:
      Returns the number of planned primary instances excluding backup instances.
      Since:
      9.6
    • getPlannedNumberOfInstances

      int getPlannedNumberOfInstances()
      For stateful processing unit (primary+backup Space) will return the current planned number of instances (including backups). For stateless processing unit will return the number of current planned instances. The plan denoted by the initial SLA may change due to increments/decrements performed manually.

      Note that this method does not count the number of running instances, but rather the number of planned number of instances for the processing unit. To count the number of currently discovered running processing unit instances use the method getInstances().

      Returns:
      Returns the number of required instances as defined in the processing unit's current SLA.
      Since:
      9.5.0
    • getNumberOfBackups

      int getNumberOfBackups()
      Returns:
      Returns the number of backups (if the topology is a backup one) per instance, as defined in the processing unit's SLA. Note that this method does not return he number of running backup instances, but rather the number of planned backup instances per primary as defined by the initial SLA.
    • getTotalNumberOfInstances

      @Deprecated int getTotalNumberOfInstances()
      Deprecated.
      - since 9.6.0 - please use getPlannedNumberOfInstances()

      Note that this method does not count the number of running instances, but rather the total number of planned instances for the processing unit. To count the number of active processing unit instances please use the method getInstances().

      Returns:
      Returns the total required number of instances as defined in the processing SLA. If there are no backups, will returngetNumberOfInstances(). If there are backups, will return getNumberOfInstances() * (getNumberOfBackups() + 1)
    • getMaxInstancesPerVM

      int getMaxInstancesPerVM()
      Returns:
      Returns the number of instances of this processing unit that can run within a VM.

      In case of a partitioned with backup topology, it applies on a per partition level (meaning that a primary and backup will not run on the same VM).

      In case of a non backup based topology, it applies on the number of instances of the whole processing unit that can run on the same VM).

    • getMaxInstancesPerMachine

      int getMaxInstancesPerMachine()
      Returns:
      Returns the number of instances of this processing unit that can run within a Machine.

      In case of a partitioned with backup topology, it applies on a per partition level (meaning that a primary and backup will not run on the same Machine).

      In case of a non backup based topology, it applies on the number of instances of the whole processing unit that can run on the same Machine).

    • isRequiresIsolation

      boolean isRequiresIsolation()
      Returns:
      true if isolation is required per virtual machine. No processing unit instances can run on the same virtual machine. Default false.
      Since:
      10.1.0
    • getMaxInstancesPerZone

      Map<String,Integer> getMaxInstancesPerZone()
      Returns:
      Returns a map containing the zone name and the maximum number of instances for that zone.
    • getRequiredZones

      @Deprecated String[] getRequiredZones()
      Deprecated.
      This method is deprecated in favor of getRequiredContainerZones()
      Returns:
      Returns the list of zones this processing units are required to run on. If there is more than one zone, the processing unit can run on either of the zones.
    • getPrimaryZones

      Set<String> getPrimaryZones()
      Returns:
      Returns the preferred zones for primary instances.
      Since:
      12.3.1
    • getRequiredContainerZones

      RequiredZonesConfig getRequiredContainerZones()
      Returns:
      the @{link GridServiceContainer} zones that can satisfy this processing unit. For example: boolean gscMatch = pu.getRequiredContainerZones().isSatisfiedBy(gsc.getExactZones());
    • getGridServiceContainers

      GridServiceContainer[] getGridServiceContainers()
      Returns:
      Returns the @{link GridServiceContainer}s this processing unit is deployed on.
      Since:
      12.2
    • getStatus

      DeploymentStatus getStatus()
      Returns:
      Returns the deployment status of the processing unit.
    • getBeanLevelProperties

      BeanLevelProperties getBeanLevelProperties()
      Returns:
      Return the deploy time properties of the processing unit.
    • getType

      Returns:
      Returns the type of processing unit: stateless, stateful, mirror, web.
      Since:
      8.0.3
    • setLogLevel

      void setLogLevel(String loggerName, String level) throws AdminException
      Throws:
      AdminException
      Since:
      15.8.0
    • waitFor

      boolean waitFor(int numberOfProcessingUnitInstances)
      Waits till at least the provided number of Processing Unit Instances are up.
      Returns:
      true if discovered the required number of instances within the default timeout and false if the waiting time elapsed before the discovery took place
    • waitFor

      boolean waitFor(int numberOfProcessingUnitInstances, long timeout, TimeUnit timeUnit)
      Waits till at least the provided number of Processing Unit Instances are up for the specified timeout.
      Returns:
      true if discovered the required number of instances within the specified timeout and false if the waiting time elapsed before the discovery took place
    • waitForSpace

      Space waitForSpace()
      Waits till an embedded Space is correlated with the processing unit.
      Returns:
      Returns the embedded Space within a processing unit if the Space was correlated within the default timeout; Otherwise null if the waiting time elapsed before correlation took place.
    • waitForSpace

      Space waitForSpace(long timeout, TimeUnit timeUnit)
      Waits till an embedded Space is correlated with the processing unit for the specified timeout.
      Returns:
      Returns the embedded Space within a processing unit if the Space was correlated within the specified timeout; Otherwise null if the waiting time elapsed before correlation took place.
    • waitForManaged

      GridServiceManager waitForManaged()
      Waits till there is a managing GridServiceManager for the processing unit.
      Returns:
      Returns the managing (primary) GSM for the processing unit if GSM was discovered within the default timeout; Otherwise null if the waiting time elapsed before discovery took place.
    • waitForManaged

      GridServiceManager waitForManaged(long timeout, TimeUnit timeUnit)
      Waits till there is a managing GridServiceManager for the processing unit for the specified timeout.
      Returns:
      Returns the managing (primary) GSM for the processing unit if GSM was discovered within the specified timeout; Otherwise null if the waiting time elapsed before discovery took place.
    • canIncrementInstance

      boolean canIncrementInstance()
      Returns:
      Returns true if this processing unit allows to increment instances on it.
    • canDecrementInstance

      boolean canDecrementInstance()
      Returns:
      Returns true if this processing unit allows to decrement instances on it.
    • incrementInstance

      void incrementInstance()
      Increments the number of processing unit instances. Does not apply for partitioned nor replicated topologies.
    • decrementInstance

      void decrementInstance()
      Removes a randomly chosen instance from the processing unit, and decrements the number of instances. For finer control use ProcessingUnitInstance.decrement() instead. Does not apply for partitioned nor replicated topologies.
      Since:
      10.1.0 decrements planned instances before decrementing an actual instance
    • isManaged

      boolean isManaged()
      Returns:
      Returns true if there is a managing GSM for it.
    • getManagingGridServiceManager

      GridServiceManager getManagingGridServiceManager()
      Returns:
      Returns the managing (primary) GSM for the processing unit.
    • getBackupGridServiceManagers

      GridServiceManager[] getBackupGridServiceManagers()
      Returns:
      Returns the backup GSMs for the processing unit.
    • getBackupGridServiceManager

      GridServiceManager getBackupGridServiceManager(String gridServiceManagerUID)
      Returns:
      Returns the backup GSM matching the provided UID.
    • undeploy

      void undeploy()
      See Also:
    • undeployAsync

      CompletableFuture<?> undeployAsync()
      Returns:
      A future which can be used to track completion
      Since:
      15.5
    • undeployAsync

      CompletableFuture<?> undeployAsync(UndeployOptions options)
      Parameters:
      options - determine the wanted drain behaviour before undeploy
      Returns:
      A future which can be used to track completion
      Since:
      16.0
      See Also:
    • undeployAndWait

      void undeployAndWait()
      Un-deploys the processing unit and waits until all instances have been undeployed. In case of an Elastic processing unit, also waits for containers to shutdown.

      The undeployment process will wait indefinitely and return when all processing units have undeployed.

      Since:
      8.0.5
      See Also:
    • undeployAndWait

      boolean undeployAndWait(long timeout, TimeUnit timeunit)
      Undeploy the processing unit and wait until all instances have been undeployed. In case of an Elastic processing unit, it waits until all containers have been removed.

      The undeployment process will wait for the given timeout and return when all processing units have undeployed or timeout expired.

      Returns:
      True if un-deploy completed successfully within the specified timeout. False if undeploy is still in progress.
      Since:
      8.0.5
      See Also:
    • hasSpace

      boolean hasSpace()
      Returns true if there are any embedded spaces, false otherwise.
      Since:
      15.5
    • getSpace

      Space getSpace()
      Returns:
      Returns the (first) embedded space within a processing unit. Returns null if no embedded space is defined within the processing unit or if no processing unit instance has been added to the processing unit.
    • getSpaces

      Space[] getSpaces()
      Returns:
      Returns all the embedded spaces within a processing unit. Returns an empty array if there are no embedded spaces defined within the processing unit, or none has been associated with the processing unit yet.
    • getInstances

      ProcessingUnitInstance[] getInstances()
      Returns:
      Returns the processing unit instances currently discovered.
    • getPartitions

      ProcessingUnitPartition[] getPartitions()
      Returns:
      Returns the processing unit partitions of this processing unit.
    • getPartition

      ProcessingUnitPartition getPartition(int partitionId)
      Returns:
      Returns a processing unit partition based on the specified partition id.
    • getProcessingUnitInstanceAdded

      ProcessingUnitInstanceAddedEventManager getProcessingUnitInstanceAdded()
      Returns:
      Returns an event manager allowing to register ProcessingUnitInstanceAddedEventListeners.
    • getProcessingUnitInstanceRemoved

      ProcessingUnitInstanceRemovedEventManager getProcessingUnitInstanceRemoved()
      Returns:
      Returns an event manager allowing to register ProcessingUnitInstanceRemovedEventListeners.
    • getProcessingUnitInstance

      ProcessingUnitInstance getProcessingUnitInstance(int instanceId, int backupId)
      Returns:
      Returns a processing unit instance based on the specified instance id and backup id
    • addLifecycleListener

      void addLifecycleListener(ProcessingUnitInstanceLifecycleEventListener eventListener)
    • removeLifecycleListener

      void removeLifecycleListener(ProcessingUnitInstanceLifecycleEventListener eventListener)
    • getManagingGridServiceManagerChanged

      ManagingGridServiceManagerChangedEventManager getManagingGridServiceManagerChanged()
      Returns:
      Returns an event manger allowing to listen for ManagingGridServiceManagerChangedEvents.
    • getBackupGridServiceManagerChanged

      BackupGridServiceManagerChangedEventManager getBackupGridServiceManagerChanged()
      Returns:
      Returns an event manager allowing to listen for BackupGridServiceManagerChangedEvents.
    • getProcessingUnitStatusChanged

      ProcessingUnitStatusChangedEventManager getProcessingUnitStatusChanged()
      Returns:
      Returns an event manager allowing to listen for ProcessingUnitStatusChangedEvents.
    • getSpaceCorrelated

      Returns:
      Returns an event manager allowing to listen for ProcessingUnitSpaceCorrelatedEvents.
    • getProcessingUnitInstanceStatisticsChanged

      ProcessingUnitInstanceStatisticsChangedEventManager getProcessingUnitInstanceStatisticsChanged()
      Returns:
      Returns a processing unit instance statistics change event manger allowing to register for events of ProcessingUnitInstanceStatisticsChangedEvent.

      Note, in order to receive events, the virtual machines need to be in a "statistics" monitored state.

    • getProcessingUnitInstanceProvisionStatusChanged

      ProcessingUnitInstanceProvisionStatusChangedEventManager getProcessingUnitInstanceProvisionStatusChanged()
      Returns:
      Returns an event manager allowing to register ProcessingUnitInstanceProvisionStatusChangedEventListeners.
      Since:
      8.0.6
    • getProcessingUnitInstanceMemberAliveIndicatorStatusChanged

      ProcessingUnitInstanceMemberAliveIndicatorStatusChangedEventManager getProcessingUnitInstanceMemberAliveIndicatorStatusChanged()
      Returns:
      Returns an event manager allowing to register ProcessingUnitInstanceMemberAliveIndicatorStatusChangedEventListeners.
      Since:
      8.0.6
    • getApplication

      Application getApplication()
      Returns:
      the application that this processing unit is associated with or null if this processing unit is not part of an application
      Since:
      8.0.3
    • getDependencies

      Returns:
      the dependencies this processing unit has on other processing units.
      Since:
      8.0.6
    • quiesce

      QuiesceResult quiesce(QuiesceRequest request)
      Requests a quiesce request from the GSM. If the request ended successfully (waitFor(com.gigaspaces.admin.quiesce.QuiesceState) returned true) all space instances and listeners will switch to quiesced mode. If the GSM rejects the request an exception with the rejection failure will be thrown. (precondition: the processing unit is intact)
      Parameters:
      request - with the quiesce description
      Returns:
      QuiesceRequest if the request was approved by the server
    • unquiesce

      void unquiesce(QuiesceRequest request)
      Requests a unquiesce request from the GSM. If the request ended successfully (waitFor(com.gigaspaces.admin.quiesce.QuiesceState) returned true) all space instances and listeners will switch to unquiesced mode. If the GSM rejects the request an exception with the rejection failure will be thrown. (precondition: the processing unit is intact)
      Parameters:
      request - with the quiesce description
    • waitFor

      boolean waitFor(QuiesceState desiredState, long timeout, TimeUnit timeUnit)
      Returns:
      true if the processing unit reached to desired as well as all instances in the requested timeout, false otherwise.
    • waitFor

      boolean waitFor(QuiesceState desiredState)
    • getQuiesceDetails

      QuiesceDetails getQuiesceDetails()
      Returns:
      the quiesce details of the processing unit - QuiesceDetails
    • getArchiveName

      String getArchiveName()
      Returns:
      the archive(jar/war etc') the pu is running with
      Since:
      12.1.0