Administering Concurrent Resources

Previous Next Contents

14 Administering Concurrent Resources

This chapter provides procedures for administering concurrent resources in the GlassFish Server environment by using the asadmin command-line utility.

The following topics are addressed here:

Instructions for accomplishing these tasks by using the Administration Console are contained in the Administration Console online help.

About Concurrent Resources

Concurrent resources are managed objects that provide concurrency capabilities to Java EE applications. In GlassFish Server, you configure concurrent resources and make them available for use by application components such as servlets and EJBs. Concurrent resources are accessed through JNDI lookup or resource injection.

Concurrent resources are resources of the following types:

For detailed information about concurrent resources, see "https://javaee.github.io/tutorial/concurrency-utilities.html[Concurrency Utilities]" in The Java EE 8 Tutorial. Also see Java Specification Request 236: Concurrency Utilities for Java EE (http://jcp.org/en/jsr/detail?id=236).

Default Concurrent Resources

When you create a concurrent resource, you specify a unique JNDI name for the resource. Applications use this name to access the resource.

The Java EE standard specifies that certain default resources be made available to applications, and defines specific JNDI names for these default resources. GlassFish Server makes these names available through the use of logical JNDI names, which map Java EE standard JNDI names to specific GlassFish Server resources. For concurrent resources, the mappings are as follows:

java:comp/DefaultContextService

This Java EE standard name is mapped to the concurrent/__defaultContextService resource.

java:comp/DefaultManagedThreadFactory

This Java EE standard name is mapped to the concurrent/__defaultManagedThreadFactory resource.

java:comp/DefaultManagedExecutorService

This Java EE standard name is mapped to the concurrent/__defaultManagedExecutorService resource.

java:comp/DefaultManagedScheduledExecutorService

This Java EE standard name is mapped to the concurrent/__defaultManagedScheduledExecutorService resource.

Configuring Context Services

Context services are used to create dynamic proxy objects that capture the context of a container and enable applications to run within that context at a later time. The context of the container is propagated to the thread executing the task.

The following tasks are used to administer context service resources:

To Create a Context Service

Use the create-context-service subcommand in remote mode to create a context service resource.

Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a context service, use only the concurrent/`name format. For example, `concurrent/Context1.

For more information about the default context service resource included with GlassFish Server, see Default Concurrent Resources.

Note

Creating a context service resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. Create a context service by using the create-context-service subcommand.

  3. If necessary, notify users that the new resource has been created.

Example 14-1 Creating a Context Service

This example creates a context service resource named concurrent/Context1.

asadmin> create-context-service concurrent/Context1
Context service concurrent/Context1 created successfully.
Command create-context-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help create-context-service at the command line.

To List Context Services

Use the list-context-services subcommand in remote mode to list the existing context service resources.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List context service resources by using the list-context-services subcommand.

Example 14-2 Listing Context Services

This example lists context service resources on the default server instance, server.

asadmin> list-context-services
concurrent/__defaultContextService
concurrent/Context1
concurrent/Context2
Command list-context-services executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help list-context-services at the command line.

To Update a Context Service

You can change all of the settings for an existing context service resource except its JNDI name. Use the get and set subcommands to view and change the values of the context service attributes.

Note

When a resource is updated, the existing resource is shut down and recreated. If an application used the resource prior to the update, the application or the server must be restarted.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the context service resources by using the list-context-services subcommand.

  3. View the attributes of a specific context service by using the get subcommand.
    For example:

asdmin> get resources.context-service.concurrent/Context1.*
  1. Set an attribute of the context service by using the set subcommand.
    For example:

asdmin> set resources.context-service.concurrent/Context1.deployment-order=120

To Delete a Context Service

Use the delete-context-service subcommand in remote mode to delete an existing context service. Deleting a context service is a dynamic event and does not require server restart.

Before deleting a context service resource, all associations to the resource must be removed.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the context service resources by using the list-context-services subcommand.

  3. If necessary, notify users that the context service is being deleted.

  4. Delete the context service by using the delete-context-service subcommand.

Example 14-3 Deleting a Context Service

This example deletes the context service resource named concurrent/Context1.

asadmin> delete-context-service concurrent/Context1
Context service concurrent/Context1 deleted successfully.
Command delete-context-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help delete-context-service at the command line.

Configuring Managed Thread Factories

Managed thread factories are used by applications to create managed threads on demand. The threads are started and managed by the container. The context of the container is propagated to the thread executing the task.

The following tasks are used to administer managed thread factory resources:

To Create a Managed Thread Factory

Use the create-managed-thread-factory subcommand in remote mode to create a managed thread factory resource.

Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a managed thread factory, use only the concurrent/`name format. For example, `concurrent/Factory1.

For more information about the default managed thread factory resource included with GlassFish Server, see Default Concurrent Resources.

Note

Creating a managed thread factory resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. Create a managed thread factory by using the create-managed-thread-factory subcommand.

  3. If necessary, notify users that the new resource has been created.

Example 14-4 Creating a Managed Thread Factory

This example creates a managed thread factory resource named concurrent/Factory1.

asadmin> create-managed-thread-factory concurrent/Factory1
Managed thread factory concurrent/Factory1 created successfully.
Command create-managed-thread-factory executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help create-managed-thread-factory at the command line.

To List Managed Thread Factories

Use the list-managed-thread-factories subcommand in remote mode to list the existing managed thread factory resources.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List managed thread factory resources by using the list-managed-thread-factories subcommand.

Example 14-5 Listing Managed Thread Factories

This example lists managed thread factory resources on the default server instance, server.

asadmin> list-managed-thread-factories
concurrent/__defaultManagedThreadFactory
concurrent/Factory1
concurrent/Factory2
Command list-managed-thread-factories executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help list-managed-thread-factories at the command line.

To Update a Managed Thread Factory

You can change all of the settings for an existing managed thread factory resource except its JNDI name. Use the get and set subcommands to view and change the values of the managed thread factory attributes.

Note

When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed thread factory resources by using the list-managed-thread-factories subcommand.

  3. View the attributes of a managed thread factory by using the get subcommand.
    For example:

asdmin> get resources.managed-thread-factory.concurrent/Factory1.*
  1. Set an attribute of the managed thread factory by using the set subcommand.
    For example:

asdmin> set resources.managed-thread-factory.concurrent/Factory1.deployment-order=120

To Delete a Managed Thread Factory

Use the delete-managed-thread-factory subcommand in remote mode to delete an existing managed thread factory. Deleting a managed thread factory is a dynamic event and does not require server restart.

Before deleting a managed thread factory resource, all associations to the resource must be removed.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed thread factory resources by using the list-managed-thread-factories subcommand.

  3. If necessary, notify users that the managed thread factory is being deleted.

  4. Delete the managed thread factory by using the delete-managed-thread-factory subcommand.

Example 14-6 Deleting a Managed Thread Factory

This example deletes the managed thread factory resource named concurrent/Factory1.

asadmin> delete-managed-thread-factory concurrent/Factory1
Managed thread factory concurrent/Factory1 deleted successfully.
Command delete-managed-thread-factory executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help delete-managed-thread-factory at the command line.

Configuring Managed Executor Services

Managed executor services are used by applications to execute submitted tasks asynchronously. Tasks are executed on threads that are started and managed by the container. The context of the container is propagated to the thread executing the task.

The following tasks are used to administer managed executor service resources:

To Create a Managed Executor Service

Use the create-managed-executor-service subcommand in remote mode to create a managed executor service resource.

Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a managed executor service, use only the concurrent/`name format. For example, `concurrent/Executor1.

For more information about the default managed executor service resource included with GlassFish Server, see Default Concurrent Resources.

Note

Creating a managed executor service resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. Create a managed executor service by using the create-managed-executor-service subcommand.

  3. If necessary, notify users that the new resource has been created.

Example 14-7 Creating a Managed Executor Service

This example creates a managed executor service resource named concurrent/Executor1.

asadmin> create-managed-executor-service concurrent/Executor1
Managed executor service concurrent/Executor1 created successfully.
Command create-managed-executor-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help create-managed-executor-service at the command line.

To List Managed Executor Services

Use the list-managed-executor-services subcommand in remote mode to list the existing managed executor service resources.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List managed executor service resources by using the list-managed-executor-services subcommand.

Example 14-8 Listing Managed Executor Services

This example lists managed executor service resources on the default server instance, server.

asadmin> list-managed-executor-services
concurrent/__defaultManagedExecutorService
concurrent/Executor1
concurrent/Executor2
Command list-managed-executor-services executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help list-managed-executor-services at the command line.

To Update a Managed Executor Service

You can change all of the settings for an existing managed executor service resource except its JNDI name. Use the get and set subcommands to view and change the values of the managed executor service attributes.

Note

When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed executor service resources by using the list-managed-executor-services subcommand.

  3. View the attributes of a managed executor service by using the get subcommand.
    For example:

asdmin> get resources.managed-executor-service.concurrent/Executor1.*
  1. Set an attribute of the managed executor service by using the set subcommand.
    For example:

asdmin> set resources.managed-executor-service.concurrent/Executor1.deployment-order=120

To Delete a Managed Executor Service

Use the delete-managed-executor-service subcommand in remote mode to delete an existing managed executor service. Deleting a managed executor service is a dynamic event and does not require server restart.

Before deleting a managed executor service resource, all associations to the resource must be removed.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed executor service resources by using the list-managed-executor-services subcommand.

  3. If necessary, notify users that the managed executor service is being deleted.

  4. Delete the managed executor service by using the delete-managed-executor-service subcommand.

Example 14-9 Deleting a Managed Executor Service

This example deletes the managed executor service resource named concurrent/Executor1.

asadmin> delete-managed-executor-service concurrent/Executor1
Managed executor service concurrent/Executor1 deleted successfully.
Command delete-managed-executor-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help delete-managed-executor-service at the command line.

Configuring Managed Scheduled Executor Services

Managed scheduled executor services are used by applications to execute submitted tasks asynchronously at specific times. Tasks are executed on threads that are started and managed by the container. The context of the container is propagated to the thread executing the task.

The following tasks are used to administer managed scheduled executor service resources:

To Create a Managed Scheduled Executor Service

Use the create-managed-scheduled-executor-service subcommand in remote mode to create a managed scheduled executor service resource.

Because all JNDI names are in the java:comp/env subcontext, when specifying the JNDI name of a managed scheduled executor service, use only the concurrent/`name format. For example, `concurrent/ScheduledExecutor1.

For more information about the default managed scheduled executor service resource included with GlassFish Server, see Default Concurrent Resources.

Note

Creating a managed scheduled executor service resource is a dynamic event and typically does not require server restart. Applications can use a resource as soon as it is created. However, if an application tried to use a resource before it was created, and that resource is created later, the application or the server must be restarted. Otherwise, the application will not be able to locate the resource.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. Create a managed scheduled executor service by using the create-managed-scheduled-executor-service subcommand.

  3. If necessary, notify users that the new resource has been created.

Example 14-10 Creating a Managed Scheduled Executor Service

This example creates a managed scheduled executor service resource named concurrent/ScheduledExecutor1.

asadmin> create-managed-scheduled-executor-service concurrent/ScheduledExecutor1
Managed scheduled executor service concurrent/ScheduledExecutor1 created successfully.
Command create-managed-scheduled-executor-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help create-managed-scheduled-executor-service at the command line.

To List Managed Scheduled Executor Services

Use the list-managed-scheduled-executor-services subcommand in remote mode to list the existing managed scheduled executor service resources.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List managed scheduled executor service resources by using the list-managed-scheduled-executor-services subcommand.

Example 14-11 Listing Managed Scheduled Executor Services

This example lists managed scheduled executor service resources on the default server instance, server.

asadmin> list-managed-scheduled-executor-services
concurrent/__defaultManagedScheduledExecutorService
concurrent/ScheduledExecutor1
concurrent/ScheduledExecutor2
Command list-managed-scheduled-executor-services executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help list-managed-scheduled-executor-services at the command line.

To Update a Managed Scheduled Executor Service

You can change all of the settings for an existing managed scheduled executor service resource except its JNDI name. Use the get and set subcommands to view and change the values of the managed scheduled executor service attributes.

Note

When a resource is updated, the existing resource is shut down and recreated. If applications used the resource prior to the update, the application or the server must be restarted.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed scheduled executor service resources by using the list-managed-scheduled-executor-services subcommand.

  3. View the attributes of a managed scheduled executor service by using the get subcommand.
    For example:

asdmin> get resources.managed-scheduled-executor-service.concurrent/ScheduledExecutor1.*
  1. Set an attribute of the managed scheduled executor service by using the set subcommand.
    For example:

asdmin> set resources.managed-scheduled-executor-service.concurrent/ScheduledExecutor1.deployment-order=120

To Delete a Managed Scheduled Executor Service

Use the delete-managed-scheduled-executor-service subcommand in remote mode to delete an existing managed scheduled executor service. Deleting a managed scheduled executor service is a dynamic event and does not require server restart.

Before deleting a managed scheduled executor service resource, all associations to the resource must be removed.

  1. Ensure that the server is running.
    Remote subcommands require a running server.

  2. List the managed scheduled executor service resources by using the list-managed-scheduled-executor-service subcommand.

  3. If necessary, notify users that the managed scheduled executor service is being deleted.

  4. Delete the managed scheduled executor service by using the delete-managed-scheduled-executor-service subcommand.

Example 14-12 Deleting a Managed Scheduled Executor Service

This example deletes the managed scheduled executor service resource named concurrent/ScheduledExecutor1.

asadmin> delete-managed-scheduled-executor-service concurrent/ScheduledExecutor1
Managed scheduled executor service concurrent/ScheduledExecutor1 deleted successfully.
Command delete-managed-scheduled-executor-service executed successfully.

See Also

You can also view the full syntax and options of the subcommand by typing asadmin help delete-managed-scheduled-executor-service at the command line.


Previous Next Contents
Eclipse Foundation Logo  Copyright © 2019, Oracle and/or its affiliates. All rights reserved.