Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-2732 flush-connection-pool is now executed on all instances #2917

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018] Payara Foundation and/or affiliates

package org.glassfish.connectors.admin.cli;

Expand All @@ -60,10 +61,17 @@
import org.jvnet.hk2.annotations.Service;

import javax.inject.Inject;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.RuntimeType;
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;

@Service(name = "flush-connection-pool")
@PerLookup
@I18n("flush.connection.pool")
@TargetType(value = {CommandTarget.DOMAIN, CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.DEPLOYMENT_GROUP,
CommandTarget.CLUSTERED_INSTANCE})
@ExecuteOn(value = {RuntimeType.ALL})
@RestEndpoints({
@RestEndpoint(configBean=Resources.class,
opType=RestEndpoint.OpType.POST,
Expand Down Expand Up @@ -95,6 +103,7 @@ public class FlushConnectionPool implements AdminCommand {
@Inject
private ConnectorRuntime _runtime;

@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();

Expand Down Expand Up @@ -122,12 +131,11 @@ public void execute(AdminCommandContext context) {
}

boolean poolingEnabled = false;
ResourcePool pool =
(ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
if(pool instanceof ConnectorConnectionPool){
ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, poolName);
if (pool instanceof ConnectorConnectionPool) {
ConnectorConnectionPool ccp = (ConnectorConnectionPool)pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
}else{
} else {
JdbcConnectionPool ccp = (JdbcConnectionPool)pool;
poolingEnabled = Boolean.valueOf(ccp.getPooling());
}
Expand All @@ -145,8 +153,7 @@ public void execute(AdminCommandContext context) {
_runtime.flushConnectionPool(poolInfo);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (ConnectorRuntimeException e) {
report.setMessage(localStrings.getLocalString("flush.connection.pool.fail",
"Flush connection pool for {0} failed", poolName));
report.setMessage(localStrings.getLocalString("flush.connection.pool.fail", "Flush connection pool for {0} failed", poolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
Expand Down