@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<ChannelFactory> executable) throws OperationFailedException { String stackName = context.getCurrentAddressValue(); ServiceName serviceName = JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stackName); ChannelFactory factory = new ActiveServiceSupplier<ChannelFactory>(context.getServiceRegistry(true), serviceName).get(); return executable.execute(context, operation, factory); } }
@Override public void register(ManagementResourceRegistration registration) { for (Operation<C> operation : this.operations) { registration.registerOperationHandler(operation.getDefinition(), this); } }
public OperationHandler(OperationExecutor<C> executor, Collection<? extends Operation<C>> operations) { this.executor = executor; for (Operation<C> executable : operations) { this.executables.put(executable.getName(), executable); } this.operations = operations; }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<ModClusterServiceMBean> executable) throws OperationFailedException { ServiceName serviceName = ProxyConfigurationResourceDefinition.Capability.SERVICE.getDefinition().getCapabilityServiceName(context.getCurrentAddress()); ModClusterServiceMBean service = new ActiveServiceSupplier<ModClusterServiceMBean>(context.getServiceRegistry(true), serviceName).get(); return (service != null) ? executable.execute(context, operation, service) : null; } }
default String getName() { return this.getDefinition().getName(); }
public OperationHandler(OperationExecutor<C> executor, Collection<? extends Operation<C>> operations) { this.executor = executor; for (Operation<C> executable : operations) { this.executables.put(executable.getName(), executable); } this.operations = operations; }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<AdvancedCache<?, ?>> executable) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress cacheAddress = address.getParent(); String cacheName = cacheAddress.getLastElement().getValue(); String containerName = cacheAddress.getParent().getLastElement().getValue(); Cache<?, ?> cache = new PassiveServiceSupplier<Cache<?, ?>>(context.getServiceRegistry(true), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName)).get(); return (cache != null) ? executable.execute(context, operation, cache.getAdvancedCache()) : null; } }
@Override public void register(ManagementResourceRegistration registration) { for (Operation<C> operation : this.operations) { registration.registerOperationHandler(operation.getDefinition(), this); } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<BackupOperationContext> executable) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress cacheAddress = address.getParent(); String site = address.getLastElement().getValue(); String cacheName = cacheAddress.getLastElement().getValue(); String containerName = cacheAddress.getParent().getLastElement().getValue(); Cache<?, ?> cache = new PassiveServiceSupplier<Cache<?, ?>>(context.getServiceRegistry(true), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName)).get(); BackupOperationContext operationContext = new BackupOperationContext() { @Override public String getSite() { return site; } @Override public XSiteAdminOperations getOperations() { return cache.getAdvancedCache().getComponentRegistry().getComponent(XSiteAdminOperations.class); } }; return (cache != null) ? executable.execute(context, operation, operationContext) : null; } }
default String getName() { return this.getDefinition().getName(); }
public void runOperation(Operation o) throws Exception{ logOperationStarted(); try{ o.execute(); } finally{ logOperationFinished(); } }
public void runOperation(Operation o) throws Exception{ logOperationStarted(); try{ o.execute(); }finally{ logOperationFinished(); } }
public class CompositeOperation implements Operation { private List<Operation> operations; public CompositeOperation(List<Operation> operations) { this.operations = (operations == null) ? new ArrayList<Operation>() : new ArrayList<Operation>(operations); } public void addOperation(Operation op) { this.operations.add(op); public double execute(double input) { double result = 0.0; // Probably a cleaner way to write this with lambdas for (Operation operation : this.operations) { result = operation.execute(input); input = result; } return result; } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<ChannelFactory> executable) throws OperationFailedException { String stackName = context.getCurrentAddressValue(); ServiceName serviceName = JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stackName); ChannelFactory factory = new ActiveServiceSupplier<ChannelFactory>(context.getServiceRegistry(true), serviceName).get(); return executable.execute(context, operation, factory); } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<ModClusterServiceMBean> executable) throws OperationFailedException { ServiceName serviceName = ProxyConfigurationResourceDefinition.Capability.SERVICE.getDefinition().getCapabilityServiceName(context.getCurrentAddress()); ModClusterServiceMBean service = new ActiveServiceSupplier<ModClusterServiceMBean>(context.getServiceRegistry(true), serviceName).get(); return (service != null) ? executable.execute(context, operation, service) : null; } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<AdvancedCache<?, ?>> executable) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress cacheAddress = address.getParent(); String cacheName = cacheAddress.getLastElement().getValue(); String containerName = cacheAddress.getParent().getLastElement().getValue(); Cache<?, ?> cache = new PassiveServiceSupplier<Cache<?, ?>>(context.getServiceRegistry(true), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName)).get(); return (cache != null) ? executable.execute(context, operation, cache.getAdvancedCache()) : null; } }
@Override public ModelNode execute(OperationContext context, ModelNode operation, Operation<BackupOperationContext> executable) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress cacheAddress = address.getParent(); String site = address.getLastElement().getValue(); String cacheName = cacheAddress.getLastElement().getValue(); String containerName = cacheAddress.getParent().getLastElement().getValue(); Cache<?, ?> cache = new PassiveServiceSupplier<Cache<?, ?>>(context.getServiceRegistry(true), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName)).get(); BackupOperationContext operationContext = new BackupOperationContext() { @Override public String getSite() { return site; } @Override public XSiteAdminOperations getOperations() { return cache.getAdvancedCache().getComponentRegistry().getComponent(XSiteAdminOperations.class); } }; return (cache != null) ? executable.execute(context, operation, operationContext) : null; } }