public MixedKeyedJDBCStoreResource() { super( MIXED_KEYED_JDBC_STORE_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.MIXED_KEYED_JDBC_STORE), CacheConfigOperationHandlers.MIXED_KEYED_JDBC_STORE_ADD, ReloadRequiredRemoveStepHandler.INSTANCE); }
public DistributedCacheResource() { super( DISTRIBUTED_CACHE_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.DISTRIBUTED_CACHE), DistributedCacheAdd.INSTANCE, CacheRemove.INSTANCE); }
public TransportResource() { super( TRANSPORT_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.TRANSPORT), CacheConfigOperationHandlers.TRANSPORT_ADD, ReloadRequiredRemoveStepHandler.INSTANCE); }
AuthorizationRoleResource() { super( PathElement.pathElement(ModelKeys.ROLE), InfinispanExtension.getResourceDescriptionResolver( ModelKeys.CACHE_CONTAINER, ModelKeys.SECURITY, ModelKeys.AUTHORIZATION, ModelKeys.ROLE), new CacheConfigAdd(ATTRIBUTES), ReloadRequiredRemoveStepHandler.INSTANCE); }
public CacheContainerResourceDefinition( final ResolvePathHandler resolvePathHandler, final boolean runtimeRegistration) { super( CONTAINER_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.CACHE_CONTAINER), CacheContainerAdd.INSTANCE, CacheContainerRemove.INSTANCE); this.resolvePathHandler = resolvePathHandler; this.runtimeRegistration = runtimeRegistration; }
/** * Resource description for the addressable resource * * <p>/subsystem=infinispan/cache-container=X/cache=Y/mixed-keyed-jdbc-store=MIXED_KEYED_JDBC_STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class MixedKeyedJDBCStoreResourceDefinition extends JDBCStoreResourceDefinition { static final PathElement PATH = PathElement.pathElement( ModelKeys.MIXED_KEYED_JDBC_STORE, ModelKeys.MIXED_KEYED_JDBC_STORE_NAME); // attributes static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] {STRING_KEYED_TABLE, BINARY_KEYED_TABLE}; // operations private static final OperationDefinition ADD_DEFINITION = new SimpleOperationDefinitionBuilder( ADD, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.MIXED_KEYED_JDBC_STORE)) .setParameters(PARAMETERS) .addParameter(DATA_SOURCE) .addParameter(DIALECT) .addParameter(STRING_KEYED_TABLE) .addParameter(BINARY_KEYED_TABLE) .build(); static void buildTransformation( ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH); JDBCStoreResourceDefinition.buildTransformation(version, builder); } MixedKeyedJDBCStoreResourceDefinition(boolean allowRuntimeOnlyRegistration) { super(StoreType.MIXED_KEYED_JDBC, allowRuntimeOnlyRegistration); } @Override public void registerAttributes(ManagementResourceRegistration registration) { super.registerAttributes(registration); // check that we don't need a special handler here? final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { registration.registerReadWriteAttribute(attr, null, writeHandler); } } // override the add operation to provide a custom definition (for the optional PROPERTIES // parameter to add()) @Override protected void registerAddOperation( final ManagementResourceRegistration registration, final OperationStepHandler handler, OperationEntry.Flag... flags) { registration.registerOperationHandler(ADD_DEFINITION, handler); } }
/** * Resource description for the addressable resource * /subsystem=infinispan/cache-container=X/cache=Y/store=STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class FileStoreResource extends BaseStoreResource { public static final PathElement FILE_STORE_PATH = PathElement.pathElement(ModelKeys.FILE_STORE); // attributes static final SimpleAttributeDefinition MAX_ENTRIES = new SimpleAttributeDefinitionBuilder(ModelKeys.MAX_ENTRIES, ModelType.INT, true) .setXmlName(Attribute.MAX_ENTRIES.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); static final SimpleAttributeDefinition PATH = new SimpleAttributeDefinitionBuilder(ModelKeys.PATH, ModelType.STRING, true) .setXmlName(Attribute.PATH.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .build(); static final SimpleAttributeDefinition RELATIVE_TO = new SimpleAttributeDefinitionBuilder(ModelKeys.RELATIVE_TO, ModelType.STRING, true) .setXmlName(Attribute.RELATIVE_TO.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setDefaultValue(new ModelNode().set(ServerEnvironment.SERVER_DATA_DIR)) .build(); static final AttributeDefinition[] FILE_STORE_ATTRIBUTES = {MAX_ENTRIES, RELATIVE_TO, PATH}; static final SimpleAttributeDefinition NAME = new SimpleAttributeDefinitionBuilder(BaseStoreResource.NAME) .setDefaultValue(new ModelNode().set(ModelKeys.FILE_STORE_NAME)) .build(); // operations private static final OperationDefinition FILE_STORE_ADD_DEFINITION = new SimpleOperationDefinitionBuilder( ADD, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.FILE_STORE)) .setParameters(COMMON_STORE_PARAMETERS) .addParameter(MAX_ENTRIES) .addParameter(RELATIVE_TO) .addParameter(PATH) .setAttributeResolver( InfinispanExtension.getResourceDescriptionResolver(ModelKeys.FILE_STORE)) .build(); private final ResolvePathHandler resolvePathHandler; public FileStoreResource(CacheResource cacheResource, ResolvePathHandler resolvePathHandler) { super(FILE_STORE_PATH, ModelKeys.FILE_STORE, cacheResource, FILE_STORE_ATTRIBUTES); this.resolvePathHandler = resolvePathHandler; } @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); } // override the add operation to provide a custom definition (for the optional PROPERTIES // parameter to add()) @Override protected void registerAddOperation( final ManagementResourceRegistration registration, final OperationStepHandler handler, OperationEntry.Flag... flags) { registration.registerOperationHandler(FILE_STORE_ADD_DEFINITION, handler); if (resolvePathHandler != null) { registration.registerOperationHandler( resolvePathHandler.getOperationDefinition(), resolvePathHandler); } } }
/** * Resource description for the addressable resource * * <p>/subsystem=infinispan/cache-container=X/cache=Y/mixed-keyed-jdbc-store=MIXED_KEYED_JDBC_STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class MixedKeyedJDBCStoreResource extends BaseJDBCStoreResource { public static final PathElement MIXED_KEYED_JDBC_STORE_PATH = PathElement.pathElement(ModelKeys.MIXED_KEYED_JDBC_STORE); // attributes static final AttributeDefinition[] MIXED_KEYED_JDBC_STORE_ATTRIBUTES = { STRING_KEYED_TABLE, BINARY_KEYED_TABLE }; static final SimpleAttributeDefinition NAME = new SimpleAttributeDefinitionBuilder(BaseStoreResource.NAME) .setDefaultValue(new ModelNode().set(ModelKeys.MIXED_KEYED_JDBC_STORE_NAME)) .build(); // operations private static final OperationDefinition MIXED_KEYED_JDBC_STORE_ADD_DEFINITION = new SimpleOperationDefinitionBuilder( ADD, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.MIXED_KEYED_JDBC_STORE)) .setParameters(COMMON_STORE_PARAMETERS) .addParameter(DATA_SOURCE) .addParameter(STRING_KEYED_TABLE) .addParameter(BINARY_KEYED_TABLE) .setAttributeResolver( InfinispanExtension.getResourceDescriptionResolver(ModelKeys.JDBC_STORE)) .build(); public MixedKeyedJDBCStoreResource() { super( MIXED_KEYED_JDBC_STORE_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.MIXED_KEYED_JDBC_STORE), CacheConfigOperationHandlers.MIXED_KEYED_JDBC_STORE_ADD, ReloadRequiredRemoveStepHandler.INSTANCE); } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { super.registerAttributes(resourceRegistration); // check that we don't need a special handler here? final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(MIXED_KEYED_JDBC_STORE_ATTRIBUTES); for (AttributeDefinition attr : MIXED_KEYED_JDBC_STORE_ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(attr, null, writeHandler); } } @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); } // override the add operation to provide a custom definition (for the optional PROPERTIES // parameter to add()) @Override protected void registerAddOperation( final ManagementResourceRegistration registration, final OperationStepHandler handler, OperationEntry.Flag... flags) { registration.registerOperationHandler(MIXED_KEYED_JDBC_STORE_ADD_DEFINITION, handler); } }
/** * Resource description for the addressable resource /subsystem=infinispan/cache-container=X * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class CacheContainerResourceDefinition extends SimpleResourceDefinition { public static final PathElement CONTAINER_PATH = PathElement.pathElement(ModelKeys.CACHE_CONTAINER); // attributes static final AttributeDefinition ALIAS = new SimpleAttributeDefinitionBuilder(ModelKeys.ALIAS, ModelType.STRING, true) .setXmlName(Attribute.NAME.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleListAttributeDefinition ALIASES = SimpleListAttributeDefinition.Builder.of(ModelKeys.ALIASES, ALIAS) .setAllowNull(true) .setAttributeMarshaller(AttributeMarshallerFactory.createSimpleListAttributeMarshaller()) .build(); static final SimpleAttributeDefinition MODULE = new SimpleAttributeDefinitionBuilder(ModelKeys.MODULE, ModelType.STRING, true) .setXmlName(Attribute.MODULE.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(new ModuleIdentifierValidator(true)) .setDefaultValue(new ModelNode().set("org.jboss.as.clustering.infinispan")) .build(); // make default-cache non required (AS7-3488) static final SimpleAttributeDefinition DEFAULT_CACHE = new SimpleAttributeDefinitionBuilder(ModelKeys.DEFAULT_CACHE, ModelType.STRING, true) .setXmlName(Attribute.DEFAULT_CACHE.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition EVICTION_EXECUTOR = new SimpleAttributeDefinitionBuilder(ModelKeys.EVICTION_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.EVICTION_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition JNDI_NAME = new SimpleAttributeDefinitionBuilder(ModelKeys.JNDI_NAME, ModelType.STRING, true) .setXmlName(Attribute.JNDI_NAME.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition LISTENER_EXECUTOR = new SimpleAttributeDefinitionBuilder(ModelKeys.LISTENER_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.LISTENER_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition NAME = new SimpleAttributeDefinitionBuilder(ModelKeys.NAME, ModelType.STRING, true) .setXmlName(Attribute.NAME.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition REPLICATION_QUEUE_EXECUTOR = new SimpleAttributeDefinitionBuilder( ModelKeys.REPLICATION_QUEUE_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.REPLICATION_QUEUE_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final SimpleAttributeDefinition START = new SimpleAttributeDefinitionBuilder(ModelKeys.START, ModelType.STRING, true) .setXmlName(Attribute.START.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setValidator(new EnumValidator<>(StartMode.class, true, false)) .setDefaultValue(new ModelNode().set(StartMode.LAZY.name())) .build(); static final SimpleAttributeDefinition STATISTICS_ENABLED = new SimpleAttributeDefinitionBuilder(ModelKeys.STATISTICS_ENABLED, ModelType.BOOLEAN, true) .setXmlName(Attribute.STATISTICS_ENABLED.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setDefaultValue(new ModelNode().set(false)) .build(); static final AttributeDefinition[] CACHE_CONTAINER_ATTRIBUTES = { DEFAULT_CACHE, ALIASES, JNDI_NAME, START, LISTENER_EXECUTOR, EVICTION_EXECUTOR, REPLICATION_QUEUE_EXECUTOR, MODULE, STATISTICS_ENABLED }; // operations static final OperationDefinition ALIAS_ADD = new SimpleOperationDefinitionBuilder( "add-alias", InfinispanExtension.getResourceDescriptionResolver("cache-container.alias")) .setParameters(NAME) .build(); static final OperationDefinition ALIAS_REMOVE = new SimpleOperationDefinitionBuilder( "remove-alias", InfinispanExtension.getResourceDescriptionResolver("cache-container.alias")) .setParameters(NAME) .build(); // metrics static final AttributeDefinition CACHE_MANAGER_STATUS = new SimpleAttributeDefinitionBuilder(MetricKeys.CACHE_MANAGER_STATUS, ModelType.STRING, true) .setStorageRuntime() .build(); static final AttributeDefinition CLUSTER_NAME = new SimpleAttributeDefinitionBuilder(MetricKeys.CLUSTER_NAME, ModelType.STRING, true) .setStorageRuntime() .build(); static final AttributeDefinition COORDINATOR_ADDRESS = new SimpleAttributeDefinitionBuilder(MetricKeys.COORDINATOR_ADDRESS, ModelType.STRING, true) .setStorageRuntime() .build(); static final AttributeDefinition IS_COORDINATOR = new SimpleAttributeDefinitionBuilder(MetricKeys.IS_COORDINATOR, ModelType.BOOLEAN, true) .setStorageRuntime() .build(); static final AttributeDefinition LOCAL_ADDRESS = new SimpleAttributeDefinitionBuilder(MetricKeys.LOCAL_ADDRESS, ModelType.STRING, true) .setStorageRuntime() .build(); static final AttributeDefinition[] CACHE_CONTAINER_METRICS = { CACHE_MANAGER_STATUS, CLUSTER_NAME, COORDINATOR_ADDRESS, IS_COORDINATOR, LOCAL_ADDRESS }; private final ResolvePathHandler resolvePathHandler; private final boolean runtimeRegistration; public CacheContainerResourceDefinition( final ResolvePathHandler resolvePathHandler, final boolean runtimeRegistration) { super( CONTAINER_PATH, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.CACHE_CONTAINER), CacheContainerAdd.INSTANCE, CacheContainerRemove.INSTANCE); this.resolvePathHandler = resolvePathHandler; this.runtimeRegistration = runtimeRegistration; } @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { // the handlers need to take account of alias final OperationStepHandler writeHandler = new CacheContainerWriteAttributeHandler(CACHE_CONTAINER_ATTRIBUTES); for (AttributeDefinition attr : CACHE_CONTAINER_ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute( attr, CacheContainerReadAttributeHandler.INSTANCE, writeHandler); } for (AttributeDefinition attr : CACHE_CONTAINER_METRICS) { resourceRegistration.registerMetric(attr, CacheContainerMetricsHandler.INSTANCE); } } @Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); // register add-alias and remove-alias resourceRegistration.registerOperationHandler( CacheContainerResourceDefinition.ALIAS_ADD, AddAliasCommand.INSTANCE); resourceRegistration.registerOperationHandler( CacheContainerResourceDefinition.ALIAS_REMOVE, RemoveAliasCommand.INSTANCE); } @Override public void registerChildren(ManagementResourceRegistration resourceRegistration) { // child resources resourceRegistration.registerSubModel(new TransportResourceDefinition()); resourceRegistration.registerSubModel( new LocalCacheResourceDefinition(this.resolvePathHandler, this.runtimeRegistration)); resourceRegistration.registerSubModel( new InvalidationCacheResourceDefinition(this.resolvePathHandler, this.runtimeRegistration)); resourceRegistration.registerSubModel( new ReplicatedCacheResourceDefinition(this.resolvePathHandler, this.runtimeRegistration)); resourceRegistration.registerSubModel( new DistributedCacheResourceDefinition(this.resolvePathHandler, this.runtimeRegistration)); } }
/** * Resource description for the addressable resource * /subsystem=infinispan/cache-container=X/cache=Y/remote-store=REMOTE_STORE * * @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public class RemoteStoreResourceDefinition extends StoreResourceDefinition { static final PathElement PATH = PathElement.pathElement(ModelKeys.REMOTE_STORE, ModelKeys.REMOTE_STORE_NAME); // attributes static final SimpleAttributeDefinition CACHE = new SimpleAttributeDefinitionBuilder(ModelKeys.CACHE, ModelType.STRING, true) .setXmlName(Attribute.CACHE.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(new ModelNode(BasicCacheContainer.DEFAULT_CACHE_NAME)) .build(); static final SimpleAttributeDefinition TCP_NO_DELAY = new SimpleAttributeDefinitionBuilder(ModelKeys.TCP_NO_DELAY, ModelType.BOOLEAN, true) .setXmlName(Attribute.TCP_NO_DELAY.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(new ModelNode().set(true)) .build(); static final SimpleAttributeDefinition SOCKET_TIMEOUT = new SimpleAttributeDefinitionBuilder(ModelKeys.SOCKET_TIMEOUT, ModelType.LONG, true) .setXmlName(Attribute.SOCKET_TIMEOUT.getLocalName()) .setMeasurementUnit(MeasurementUnit.MILLISECONDS) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .setDefaultValue(new ModelNode().set(60000L)) .build(); // the remote servers parameter is required (not null), and the list of remote-server objects must // have size >= 1 static final SimpleAttributeDefinition OUTBOUND_SOCKET_BINDING = new SimpleAttributeDefinitionBuilder(ModelKeys.OUTBOUND_SOCKET_BINDING, ModelType.STRING) .setAllowNull(false) .setXmlName(Attribute.OUTBOUND_SOCKET_BINDING.getLocalName()) .build(); static final ObjectTypeAttributeDefinition REMOTE_SERVER = ObjectTypeAttributeDefinition.Builder.of(ModelKeys.REMOTE_SERVER, OUTBOUND_SOCKET_BINDING) .setAllowNull(false) .setSuffix("remote-server") .build(); static final ObjectListAttributeDefinition REMOTE_SERVERS = ObjectListAttributeDefinition.Builder.of(ModelKeys.REMOTE_SERVERS, REMOTE_SERVER) .setAllowNull(false) .setMinSize(1) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] {CACHE, TCP_NO_DELAY, SOCKET_TIMEOUT, REMOTE_SERVERS}; // operations private static final OperationDefinition ADD_DEFINITION = new SimpleOperationDefinitionBuilder( ADD, InfinispanExtension.getResourceDescriptionResolver(ModelKeys.REMOTE_STORE)) .setParameters(PARAMETERS) .addParameter(CACHE) .addParameter(TCP_NO_DELAY) .addParameter(SOCKET_TIMEOUT) .addParameter(REMOTE_SERVERS) .setAttributeResolver( InfinispanExtension.getResourceDescriptionResolver(ModelKeys.REMOTE_STORE)) .build(); static void buildTransformation( ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH); if (InfinispanModel.VERSION_1_4_0.requiresTransformation(version)) { builder .getAttributeBuilder() .addRejectCheck( RejectAttributeChecker.SIMPLE_EXPRESSIONS, CACHE, SOCKET_TIMEOUT, TCP_NO_DELAY); } StoreResourceDefinition.buildTransformation(version, builder); } RemoteStoreResourceDefinition(boolean allowRuntimeOnlyRegistration) { super(StoreType.REMOTE, allowRuntimeOnlyRegistration); } @Override public void registerAttributes(ManagementResourceRegistration registration) { super.registerAttributes(registration); // check that we don't need a special handler here? final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { registration.registerReadWriteAttribute(attr, null, writeHandler); } } // override the add operation to provide a custom definition (for the optional PROPERTIES // parameter to add()) @Override protected void registerAddOperation( final ManagementResourceRegistration registration, final OperationStepHandler handler, OperationEntry.Flag... flags) { registration.registerOperationHandler(ADD_DEFINITION, handler); } }