Skip to content

Commit

Permalink
PAYARA-2732 flush-connection-pool fails in a clustered environment - …
Browse files Browse the repository at this point in the history
…Payara4 (#2933)

* PAYARA-2732 flush-connection-pool fails in a clustered environment (#2917)

* flush-connection-pool is now executed on all instances.
* Added cluster_instance to target types.

* removed deployment group
  • Loading branch information
Cousjava authored and smillidge committed Jul 11, 2018
1 parent c4a6c96 commit 01e3e6c
Showing 1 changed file with 12 additions and 6 deletions.
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,16 @@
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.CLUSTERED_INSTANCE})
@ExecuteOn(value = {RuntimeType.ALL})
@RestEndpoints({
@RestEndpoint(configBean=Resources.class,
opType=RestEndpoint.OpType.POST,
Expand Down Expand Up @@ -95,6 +102,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 +130,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 +152,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

0 comments on commit 01e3e6c

Please sign in to comment.