From 4c2821812f2d5eee6df276efb3aa05f458aa01b4 Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Sat, 11 Nov 2017 17:08:35 -0500 Subject: [PATCH] WFLY-8417 Create DistributedWorkManager implementation based on WF clustering API --- .../server/group/AddressableNode.java | 4 +- connector/pom.xml | 15 +- .../DistributedWorkManagerService.java | 28 +- .../transport/AddWorkManagerCommand.java | 52 ++++ .../ClearDistributedStatisticsCommand.java | 46 ++++ .../transport/CommandDispatcherTransport.java | 259 ++++++++++++++++++ ...patcherTransportClassTableContributor.java | 57 ++++ .../transport/DeltaDoWorkAcceptedCommand.java | 46 ++++ .../transport/DeltaDoWorkRejectedCommand.java | 46 ++++ .../DeltaScheduleWorkAcceptedCommand.java | 46 ++++ .../DeltaScheduleWorkRejectedCommand.java | 46 ++++ .../DeltaStartWorkAcceptedCommand.java | 46 ++++ .../DeltaStartWorkRejectedCommand.java | 46 ++++ .../transport/DeltaWorkFailedCommand.java | 46 ++++ .../transport/DeltaWorkSuccessfulCommand.java | 46 ++++ .../DistributedStatisticsCommand.java | 46 ++++ .../workmanager/transport/DoWorkCommand.java | 51 ++++ .../transport/ForkChannelTransport.java | 62 ----- .../transport/GetWorkManagersCommand.java | 41 +++ .../workmanager/transport/JoinCommand.java | 40 +++ .../workmanager/transport/LeaveCommand.java | 46 ++++ .../transport/LongRunningFreeCommand.java | 45 +++ .../workmanager/transport/PingCommand.java | 38 +++ .../transport/RemoveWorkManagerCommand.java | 46 ++++ .../transport/ScheduleWorkCommand.java | 51 ++++ .../transport/ShortRunningFreeCommand.java | 45 +++ .../transport/StartWorkCommand.java | 50 ++++ .../UpdateLongRunningFreeCommand.java | 48 ++++ .../UpdateShortRunningFreeCommand.java | 48 ++++ .../jca/DistributedWorkManagerAdd.java | 6 +- .../JcaDistributedWorkManagerDefinition.java | 4 +- .../subsystems/jca/JcaSubsystemTestCase.java | 4 +- .../org/jboss/as/connector/main/module.xml | 7 +- 33 files changed, 1414 insertions(+), 93 deletions(-) create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/AddWorkManagerCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ClearDistributedStatisticsCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransport.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransportClassTableContributor.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkAcceptedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkRejectedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkAcceptedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkRejectedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkAcceptedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkRejectedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkFailedCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkSuccessfulCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DistributedStatisticsCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DoWorkCommand.java delete mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ForkChannelTransport.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/GetWorkManagersCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/JoinCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LeaveCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LongRunningFreeCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/PingCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/RemoveWorkManagerCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ScheduleWorkCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ShortRunningFreeCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/StartWorkCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateLongRunningFreeCommand.java create mode 100644 connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateShortRunningFreeCommand.java diff --git a/clustering/server/src/main/java/org/wildfly/clustering/server/group/AddressableNode.java b/clustering/server/src/main/java/org/wildfly/clustering/server/group/AddressableNode.java index cff92755fd52..40e6442268e7 100644 --- a/clustering/server/src/main/java/org/wildfly/clustering/server/group/AddressableNode.java +++ b/clustering/server/src/main/java/org/wildfly/clustering/server/group/AddressableNode.java @@ -21,6 +21,7 @@ */ package org.wildfly.clustering.server.group; +import java.io.Serializable; import java.net.InetSocketAddress; import org.jgroups.Address; @@ -32,7 +33,8 @@ * and transport socket binding. * @author Paul Ferraro */ -public class AddressableNode implements Node, Addressable, Comparable { +public class AddressableNode implements Node, Addressable, Comparable, Serializable { + private static final long serialVersionUID = -7707210981640344598L; private final Address address; private final String name; diff --git a/connector/pom.xml b/connector/pom.xml index 8299b9b8af2c..0b7a6f9b2402 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -33,13 +33,21 @@ wildfly-connector WildFly: Connector Subsystem + + org.jgroups + jgroups + org.wildfly.core wildfly-server org.wildfly - wildfly-clustering-jgroups-spi + wildfly-clustering-marshalling-jboss + + + org.wildfly + wildfly-clustering-spi org.wildfly @@ -122,6 +130,11 @@ provided true + + org.kohsuke.metainf-services + metainf-services + provided + javax.validation validation-api diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/DistributedWorkManagerService.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/DistributedWorkManagerService.java index a7d3668dbf84..0f5d8dac6969 100644 --- a/connector/src/main/java/org/jboss/as/connector/services/workmanager/DistributedWorkManagerService.java +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/DistributedWorkManagerService.java @@ -27,14 +27,13 @@ import java.util.concurrent.Executor; import org.jboss.as.connector.security.ElytronSecurityIntegration; -import org.jboss.as.connector.services.workmanager.transport.ForkChannelTransport; +import org.jboss.as.connector.services.workmanager.transport.CommandDispatcherTransport; import org.jboss.as.connector.util.ConnectorServices; import org.jboss.as.txn.integration.JBossContextXATerminator; import org.jboss.jca.core.security.picketbox.PicketBoxSecurityIntegration; import org.jboss.jca.core.spi.workmanager.Address; import org.jboss.jca.core.tx.jbossts.XATerminatorImpl; import org.jboss.jca.core.workmanager.WorkManagerCoordinator; -import org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport; import org.jboss.msc.inject.Injector; import org.jboss.msc.service.Service; import org.jboss.msc.service.StartContext; @@ -42,7 +41,7 @@ import org.jboss.msc.service.StopContext; import org.jboss.msc.value.InjectedValue; import org.jboss.threads.BlockingExecutor; -import org.wildfly.clustering.jgroups.spi.ChannelFactory; +import org.wildfly.clustering.dispatcher.CommandDispatcherFactory; /** * A WorkManager Service. @@ -60,7 +59,7 @@ public final class DistributedWorkManagerService implements Service xaTerminator = new InjectedValue(); - private final InjectedValue jGroupsChannelFactory = new InjectedValue(); + private final InjectedValue dispatcherFactory = new InjectedValue<>(); /** * create an instance @@ -82,16 +81,9 @@ public NamedDistributedWorkManager getValue() throws IllegalStateException { public void start(StartContext context) throws StartException { ROOT_LOGGER.debugf("Starting JCA DistributedWorkManager: ", value.getName()); - ChannelFactory factory = this.jGroupsChannelFactory.getValue(); - JGroupsTransport transport = new ForkChannelTransport(factory); - try { - transport.setChannel(factory.createChannel(this.value.getName())); - transport.setClusterName(this.value.getName()); - this.value.setTransport(transport); - } catch (Exception e) { - ROOT_LOGGER.trace("failed to start JGroups channel", e); - throw ROOT_LOGGER.failedToStartJGroupsChannel(this.value.getName(), this.value.getName()); - } + CommandDispatcherTransport transport = new CommandDispatcherTransport(this.dispatcherFactory.getValue(), this.value.getName()); + + this.value.setTransport(transport); BlockingExecutor longRunning = (BlockingExecutor) executorLong.getOptionalValue(); if (longRunning != null) { @@ -111,7 +103,6 @@ public void start(StartContext context) throws StartException { } else { this.value.setSecurityIntegration(new PicketBoxSecurityIntegration()); } - transport.setId(String.valueOf(transport.getChannel().hashCode())); try { transport.startup(); @@ -119,7 +110,7 @@ public void start(StartContext context) throws StartException { ROOT_LOGGER.trace("failed to start DWM transport:", throwable); throw ROOT_LOGGER.failedToStartDWMTransport(this.value.getName()); } - transport.register(new Address(value.getId(), value.getName(), value.getTransport().getId())); + transport.register(new Address(value.getId(), value.getName(), transport.getId())); WorkManagerCoordinator.getInstance().registerWorkManager(value); @@ -159,8 +150,7 @@ public Injector getXaTerminatorInjector() { return xaTerminator; } - public Injector getJGroupsChannelFactoryInjector() { - return jGroupsChannelFactory; + public Injector getCommandDispatcherFactoryInjector() { + return this.dispatcherFactory; } - } diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/AddWorkManagerCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/AddWorkManagerCommand.java new file mode 100644 index 000000000000..56f737528937 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/AddWorkManagerCommand.java @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; +import org.wildfly.clustering.group.Node; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#addWorkManager(java.util.Map, org.jgroups.Address)}. + * @author Paul Ferraro + */ +public class AddWorkManagerCommand implements Command { + private static final long serialVersionUID = -6747024371979702527L; + + private final Address address; + private final Node member; + + public AddWorkManagerCommand(Address address, Node member) { + this.address = address; + this.member = member; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localWorkManagerAdd(this.address, this.member); + + transport.localUpdateShortRunningFree(this.address, transport.getShortRunningFree(this.address)); + transport.localUpdateLongRunningFree(this.address, transport.getLongRunningFree(this.address)); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ClearDistributedStatisticsCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ClearDistributedStatisticsCommand.java new file mode 100644 index 000000000000..d577d6fed78e --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ClearDistributedStatisticsCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#clearDistributedStatistics(java.util.Map)}. + * @author Paul Ferraro + */ +public class ClearDistributedStatisticsCommand implements Command { + private static final long serialVersionUID = -1590205163985739077L; + + private final Address address; + + public ClearDistributedStatisticsCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localClearDistributedStatistics(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransport.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransport.java new file mode 100644 index 000000000000..eb8f31d2dc51 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransport.java @@ -0,0 +1,259 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import java.io.Serializable; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import javax.resource.spi.work.DistributableWork; +import javax.resource.spi.work.WorkException; + +import org.jboss.as.connector.logging.ConnectorLogger; +import org.jboss.jca.core.api.workmanager.DistributedWorkManager; +import org.jboss.jca.core.spi.workmanager.Address; +import org.jboss.jca.core.workmanager.transport.remote.AbstractRemoteTransport; +import org.jboss.jca.core.workmanager.transport.remote.ProtocolMessages.Request; +import org.wildfly.clustering.dispatcher.Command; +import org.wildfly.clustering.dispatcher.CommandDispatcher; +import org.wildfly.clustering.dispatcher.CommandDispatcherException; +import org.wildfly.clustering.dispatcher.CommandDispatcherFactory; +import org.wildfly.clustering.dispatcher.CommandResponse; +import org.wildfly.clustering.group.Group; +import org.wildfly.clustering.group.Node; +import org.wildfly.clustering.service.concurrent.ServiceExecutor; +import org.wildfly.clustering.service.concurrent.StampedLockServiceExecutor; +import org.wildfly.common.function.ExceptionSupplier; + +/** + * {@link DistributedWorkManager}-specific transport based on a {@link CommandDispatcher}. + * The current implementation is a direct translation of {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport}. + * @author Paul Ferraro + */ +public class CommandDispatcherTransport extends AbstractRemoteTransport implements Group.Listener { + + private final ServiceExecutor executor = new StampedLockServiceExecutor(); + private final CommandDispatcherFactory dispatcherFactory; + private final String name; + + private volatile CommandDispatcher dispatcher; + private volatile boolean initialized = false; + + public CommandDispatcherTransport(CommandDispatcherFactory dispatcherFactory, String name) { + this.dispatcherFactory = dispatcherFactory; + this.name = name; + } + + @Override + public String getId() { + return this.getOwnAddress().getName(); + } + + @Override + public void startup() throws Exception { + this.dispatcher = this.dispatcherFactory.createCommandDispatcher(this.name, this); + this.dispatcherFactory.getGroup().addListener(this); + this.broadcast(new JoinCommand()); + } + + @Override + public void shutdown() { + this.executor.close(() -> { + try { + this.broadcast(new LeaveCommand(this.getOwnAddress())); + } catch (WorkException e) { + ConnectorLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e); + } finally { + this.dispatcherFactory.getGroup().removeListener(this); + this.dispatcher.close(); + } + }); + } + + @Override + public void initialize() throws Exception { + this.initialized = true; + } + + @Override + public boolean isInitialized() { + return this.initialized; + } + + @Override + protected Node getOwnAddress() { + return this.dispatcherFactory.getGroup().getLocalNode(); + } + + @Override + protected Serializable sendMessage(Node physicalAddress, Request request, Serializable... parameters) throws WorkException { + Command command = createCommand(request, parameters); + ExceptionSupplier, CommandDispatcherException> task = () -> this.dispatcher.executeOnNode(command, physicalAddress); + try { + CommandResponse response = this.executor.execute(task).orElse(null); + return (response != null) ? (Serializable) response.get() : null; + } catch (CommandDispatcherException | ExecutionException e) { + throw new WorkException(e); + } + } + + private void broadcast(Command command) throws WorkException { + ExceptionSupplier>, CommandDispatcherException> task = () -> this.dispatcher.executeOnCluster(command); + try { + Map> responses = this.executor.execute(task).orElse(Collections.emptyMap()); + for (Map.Entry> entry : responses.entrySet()) { + // Verify that command executed successfully on all nodes + entry.getValue().get(); + } + } catch (CommandDispatcherException | ExecutionException e) { + throw new WorkException(e); + } + } + + private static Command createCommand(Request request, Serializable... parameters) { + Address address = (parameters.length > 0) ? (Address) parameters[0] : null; + switch (request) { + case CLEAR_DISTRIBUTED_STATISTICS: { + return new ClearDistributedStatisticsCommand(address); + } + case DELTA_DOWORK_ACCEPTED: { + return new DeltaDoWorkAcceptedCommand(address); + } + case DELTA_DOWORK_REJECTED: { + return new DeltaDoWorkRejectedCommand(address); + } + case DELTA_SCHEDULEWORK_ACCEPTED: { + return new DeltaScheduleWorkAcceptedCommand(address); + } + case DELTA_SCHEDULEWORK_REJECTED: { + return new DeltaScheduleWorkRejectedCommand(address); + } + case DELTA_STARTWORK_ACCEPTED: { + return new DeltaStartWorkAcceptedCommand(address); + } + case DELTA_STARTWORK_REJECTED: { + return new DeltaStartWorkRejectedCommand(address); + } + case DELTA_WORK_FAILED: { + return new DeltaWorkFailedCommand(address); + } + case DELTA_WORK_SUCCESSFUL: { + return new DeltaWorkSuccessfulCommand(address); + } + case DO_WORK: { + return new DoWorkCommand(address, (DistributableWork) parameters[2]); + } + case GET_DISTRIBUTED_STATISTICS: { + return new DistributedStatisticsCommand(address); + } + case GET_LONGRUNNING_FREE: { + return new LongRunningFreeCommand(address); + } + case GET_SHORTRUNNING_FREE: { + return new ShortRunningFreeCommand(address); + } + case PING: { + return new PingCommand(); + } + case SCHEDULE_WORK: { + return new ScheduleWorkCommand(address, (DistributableWork) parameters[2]); + } + case START_WORK: { + return new StartWorkCommand(address, (DistributableWork) parameters[2]); + } + case UPDATE_LONGRUNNING_FREE: { + return new UpdateLongRunningFreeCommand(address, (Long) parameters[1]); + } + case UPDATE_SHORTRUNNING_FREE: { + return new UpdateShortRunningFreeCommand(address, (Long) parameters[1]); + } + case WORKMANAGER_ADD: { + return new AddWorkManagerCommand(address, (Node) parameters[1]); + } + case WORKMANAGER_REMOVE: { + return new RemoveWorkManagerCommand(address); + } + default: { + throw new IllegalStateException(request.name()); + } + } + } + + @Override + public void membershipChanged(List previousMembers, List members, boolean merged) { + Runnable task = () -> { + Set leavers = new HashSet<>(previousMembers); + leavers.removeAll(members); + // Handle abrupt leavers + for (Node leaver : leavers) { + this.leave(leaver); + } + + if (merged) { + this.join(members); + } + }; + this.executor.execute(task); + } + + public void join() { + this.join(this.dispatcherFactory.getGroup().getNodes()); + } + + private void join(List members) { + Map>> futures = new HashMap<>(); + for (Node member : members) { + if (!this.getOwnAddress().equals(member) && !this.nodes.containsValue(member)) { + try { + futures.put(member, this.dispatcher.submitOnNode(new GetWorkManagersCommand(), member)); + } catch (CommandDispatcherException e) { + ConnectorLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e); + } + } + } + try { + for (Map.Entry>> entry : futures.entrySet()) { + Node member = entry.getKey(); + try { + Set
addresses = entry.getValue().get(); + for (Address address : addresses) { + this.join(address, member); + + this.localUpdateLongRunningFree(address, this.getShortRunningFree(address)); + this.localUpdateShortRunningFree(address, this.getShortRunningFree(address)); + } + } catch (ExecutionException e) { + ConnectorLogger.ROOT_LOGGER.warn(e.getLocalizedMessage(), e); + } + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransportClassTableContributor.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransportClassTableContributor.java new file mode 100644 index 000000000000..9ff82bd4c9c4 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/CommandDispatcherTransportClassTableContributor.java @@ -0,0 +1,57 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import java.util.Arrays; +import java.util.List; + +import javax.resource.spi.work.DistributableWork; +import javax.resource.spi.work.Work; + +import org.jboss.jca.core.api.workmanager.DistributedWorkManagerStatisticsValues; +import org.jboss.jca.core.spi.workmanager.Address; +import org.kohsuke.MetaInfServices; +import org.wildfly.clustering.marshalling.jboss.ClassTableContributor; + +/** + * {@link ClassTableContributor} for a {@link CommandDispatcherTransport}. + * @author Paul Ferraro + */ +@MetaInfServices(ClassTableContributor.class) +public class CommandDispatcherTransportClassTableContributor implements ClassTableContributor { + + @Override + public List> getKnownClasses() { + return Arrays.asList(Address.class, DistributedWorkManagerStatisticsValues.class, + DistributableWork.class, Work.class, GetWorkManagersCommand.class, + DeltaDoWorkAcceptedCommand.class, DeltaDoWorkRejectedCommand.class, + DeltaScheduleWorkAcceptedCommand.class, DeltaScheduleWorkRejectedCommand.class, + DeltaStartWorkAcceptedCommand.class, DeltaStartWorkRejectedCommand.class, + DeltaWorkFailedCommand.class, DeltaWorkSuccessfulCommand.class, + ClearDistributedStatisticsCommand.class, DistributedStatisticsCommand.class, + PingCommand.class, LongRunningFreeCommand.class, ShortRunningFreeCommand.class, + DoWorkCommand.class, StartWorkCommand.class, ScheduleWorkCommand.class, + UpdateLongRunningFreeCommand.class, UpdateShortRunningFreeCommand.class, + JoinCommand.class, LeaveCommand.class); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkAcceptedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkAcceptedCommand.java new file mode 100644 index 000000000000..8509dbeccce8 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkAcceptedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaDoWorkAccepted(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaDoWorkAcceptedCommand implements Command { + private static final long serialVersionUID = -2256088009794548082L; + + private final Address address; + + public DeltaDoWorkAcceptedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaDoWorkAccepted(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkRejectedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkRejectedCommand.java new file mode 100644 index 000000000000..1c71aaf60450 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaDoWorkRejectedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaDoWorkRejected(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaDoWorkRejectedCommand implements Command { + private static final long serialVersionUID = 7864134087221121821L; + + private final Address address; + + public DeltaDoWorkRejectedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaDoWorkRejected(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkAcceptedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkAcceptedCommand.java new file mode 100644 index 000000000000..a19e25f9987e --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkAcceptedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaScheduleWorkAccepted(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaScheduleWorkAcceptedCommand implements Command { + private static final long serialVersionUID = -3878717003141874003L; + + private final Address address; + + public DeltaScheduleWorkAcceptedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaScheduleWorkAccepted(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkRejectedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkRejectedCommand.java new file mode 100644 index 000000000000..438f6fd7af78 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaScheduleWorkRejectedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaScheduleWorkRejected(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaScheduleWorkRejectedCommand implements Command { + private static final long serialVersionUID = 5726410485723041645L; + + private final Address address; + + public DeltaScheduleWorkRejectedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaScheduleWorkRejected(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkAcceptedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkAcceptedCommand.java new file mode 100644 index 000000000000..4bbf5b599bc2 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkAcceptedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaStartWorkAccepted(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaStartWorkAcceptedCommand implements Command { + private static final long serialVersionUID = -2940831151921131815L; + + private final Address address; + + public DeltaStartWorkAcceptedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaStartWorkAccepted(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkRejectedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkRejectedCommand.java new file mode 100644 index 000000000000..5ef2f4b06d2a --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaStartWorkRejectedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaStartWorkRejected(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaStartWorkRejectedCommand implements Command { + private static final long serialVersionUID = -1980521523518562227L; + + private final Address address; + + public DeltaStartWorkRejectedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaStartWorkRejected(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkFailedCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkFailedCommand.java new file mode 100644 index 000000000000..41e49be66f3d --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkFailedCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaWorkFailed(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaWorkFailedCommand implements Command { + private static final long serialVersionUID = 8092302980939329432L; + + private final Address address; + + public DeltaWorkFailedCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaWorkFailed(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkSuccessfulCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkSuccessfulCommand.java new file mode 100644 index 000000000000..aafdc04162f8 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DeltaWorkSuccessfulCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#deltaWorkSuccessful(java.util.Map)}. + * @author Paul Ferraro + */ +public class DeltaWorkSuccessfulCommand implements Command { + private static final long serialVersionUID = -3397082802806176447L; + + private final Address address; + + public DeltaWorkSuccessfulCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localDeltaWorkSuccessful(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DistributedStatisticsCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DistributedStatisticsCommand.java new file mode 100644 index 000000000000..775fb74031bc --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DistributedStatisticsCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.api.workmanager.DistributedWorkManagerStatisticsValues; +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#getDistributedStatistics(java.util.Map)}. + * @author Paul Ferraro + */ +public class DistributedStatisticsCommand implements Command { + private static final long serialVersionUID = -8884303103746998259L; + + private final Address address; + + public DistributedStatisticsCommand(Address address) { + this.address = address; + } + + @Override + public DistributedWorkManagerStatisticsValues execute(CommandDispatcherTransport transport) { + return transport.localGetDistributedStatistics(this.address); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DoWorkCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DoWorkCommand.java new file mode 100644 index 000000000000..156f53b1eedb --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/DoWorkCommand.java @@ -0,0 +1,51 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import javax.resource.spi.work.DistributableWork; +import javax.resource.spi.work.WorkException; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#doWork(Address, DistributableWork)}. + * @author Paul Ferraro + */ +public class DoWorkCommand implements Command { + private static final long serialVersionUID = -661447249010320508L; + + private final Address address; + private final DistributableWork work; + + public DoWorkCommand(Address address, DistributableWork work) { + this.address = address; + this.work = work; + } + + @Override + public Void execute(CommandDispatcherTransport transport) throws WorkException { + transport.localDoWork(this.address, this.work); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ForkChannelTransport.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ForkChannelTransport.java deleted file mode 100644 index a426c0ac09dd..000000000000 --- a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ForkChannelTransport.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2015, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.as.connector.services.workmanager.transport; - -import java.nio.ByteBuffer; - -import org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport; -import org.jgroups.blocks.RpcDispatcher; -import org.jgroups.blocks.RpcDispatcher.Marshaller; -import org.jgroups.util.Buffer; -import org.jgroups.util.Util; -import org.wildfly.clustering.jgroups.spi.ChannelFactory; - -/** - * A {@link JGroupsTransport} capable of handling unknown fork responses. - * @author Paul Ferraro - */ -public class ForkChannelTransport extends JGroupsTransport implements Marshaller { - - private final ChannelFactory factory; - - public ForkChannelTransport(ChannelFactory factory) { - this.factory = factory; - } - - @Override - protected RpcDispatcher createRpcDispatcher() { - RpcDispatcher dispatcher = super.createRpcDispatcher(); - dispatcher.setResponseMarshaller(this); - return dispatcher; - } - - @Override - public Buffer objectToBuffer(Object obj) throws Exception { - return new Buffer(Util.objectToByteBuffer(obj)); - } - - @Override - public Object objectFromBuffer(byte[] buffer, int offset, int length) throws Exception { - return this.factory.isUnknownForkResponse(ByteBuffer.wrap(buffer, offset, length)) ? null : Util.objectFromByteBuffer(buffer, offset, length); - } -} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/GetWorkManagersCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/GetWorkManagersCommand.java new file mode 100644 index 000000000000..2ce4730bd943 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/GetWorkManagersCommand.java @@ -0,0 +1,41 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import java.util.Set; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#getAddresses(org.jgroups.Address)}. + * @author Paul Ferraro + */ +public class GetWorkManagersCommand implements Command, CommandDispatcherTransport> { + private static final long serialVersionUID = 8595995018539997003L; + + @Override + public Set
execute(CommandDispatcherTransport transport) { + return transport.getAddresses(transport.getOwnAddress()); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/JoinCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/JoinCommand.java new file mode 100644 index 000000000000..d996a4011ca5 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/JoinCommand.java @@ -0,0 +1,40 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#viewAccepted(org.jgroups.View)}. + * @author Paul Ferraro + */ +public class JoinCommand implements Command { + + private static final long serialVersionUID = 2120774292518363374L; + + @Override + public Void execute(CommandDispatcherTransport transport) throws Exception { + transport.join(); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LeaveCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LeaveCommand.java new file mode 100644 index 000000000000..722bcba4773d --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LeaveCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.wildfly.clustering.dispatcher.Command; +import org.wildfly.clustering.group.Node; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#viewAccepted(org.jgroups.View)}. + * @author Paul Ferraro + */ +public class LeaveCommand implements Command { + private static final long serialVersionUID = -3857530778548976078L; + + private final Node member; + + public LeaveCommand(Node member) { + this.member = member; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.leave(this.member); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LongRunningFreeCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LongRunningFreeCommand.java new file mode 100644 index 000000000000..4ba8bdc3e7f0 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/LongRunningFreeCommand.java @@ -0,0 +1,45 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#getLongRunningFree(java.util.Map)}. + * @author Paul Ferraro + */ +public class LongRunningFreeCommand implements Command { + private static final long serialVersionUID = -3552549556601333089L; + + private final Address address; + + public LongRunningFreeCommand(Address address) { + this.address = address; + } + + @Override + public Long execute(CommandDispatcherTransport transport) { + return transport.localGetLongRunningFree(this.address); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/PingCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/PingCommand.java new file mode 100644 index 000000000000..65f12b7c8959 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/PingCommand.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#localPing()}. + * @author Paul Ferraro + */ +public class PingCommand implements Command { + private static final long serialVersionUID = 7747022347047976535L; + + @Override + public Long execute(CommandDispatcherTransport transport) { + return transport.localPing(); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/RemoveWorkManagerCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/RemoveWorkManagerCommand.java new file mode 100644 index 000000000000..e73ee4535934 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/RemoveWorkManagerCommand.java @@ -0,0 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#workManagerRemove(java.util.Map)}. + * @author Paul Ferraro + */ +public class RemoveWorkManagerCommand implements Command { + private static final long serialVersionUID = 2582985650458275860L; + + private final Address address; + + public RemoveWorkManagerCommand(Address address) { + this.address = address; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localWorkManagerRemove(this.address); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ScheduleWorkCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ScheduleWorkCommand.java new file mode 100644 index 000000000000..fd0718eed7fb --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ScheduleWorkCommand.java @@ -0,0 +1,51 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import javax.resource.spi.work.DistributableWork; +import javax.resource.spi.work.WorkException; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#scheduleWork(Address, DistributableWork)}. + * @author Paul Ferraro + */ +public class ScheduleWorkCommand implements Command { + private static final long serialVersionUID = -661447249010320508L; + + private final Address address; + private final DistributableWork work; + + public ScheduleWorkCommand(Address address, DistributableWork work) { + this.address = address; + this.work = work; + } + + @Override + public Void execute(CommandDispatcherTransport transport) throws WorkException { + transport.localScheduleWork(this.address, this.work); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ShortRunningFreeCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ShortRunningFreeCommand.java new file mode 100644 index 000000000000..1245ef392b17 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/ShortRunningFreeCommand.java @@ -0,0 +1,45 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#getShortRunningFree(java.util.Map)}. + * @author Paul Ferraro + */ +public class ShortRunningFreeCommand implements Command { + private static final long serialVersionUID = 2200993132804378135L; + + private final Address address; + + public ShortRunningFreeCommand(Address address) { + this.address = address; + } + + @Override + public Long execute(CommandDispatcherTransport transport) { + return transport.localGetShortRunningFree(this.address); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/StartWorkCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/StartWorkCommand.java new file mode 100644 index 000000000000..691d8503bebb --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/StartWorkCommand.java @@ -0,0 +1,50 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import javax.resource.spi.work.DistributableWork; +import javax.resource.spi.work.WorkException; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#startWork(Address, DistributableWork)}. + * @author Paul Ferraro + */ +public class StartWorkCommand implements Command { + private static final long serialVersionUID = -661447249010320508L; + + private final Address address; + private final DistributableWork work; + + public StartWorkCommand(Address address, DistributableWork work) { + this.address = address; + this.work = work; + } + + @Override + public Long execute(CommandDispatcherTransport transport) throws WorkException { + return transport.localStartWork(this.address, this.work); + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateLongRunningFreeCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateLongRunningFreeCommand.java new file mode 100644 index 000000000000..2551929b9f81 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateLongRunningFreeCommand.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#updateLongRunningFree(java.util.Map, Long)}. + * @author Paul Ferraro + */ +public class UpdateLongRunningFreeCommand implements Command { + private static final long serialVersionUID = -3887902059566674034L; + + private final Address address; + private final long free; + + public UpdateLongRunningFreeCommand(Address address, long free) { + this.address = address; + this.free = free; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localUpdateLongRunningFree(this.address, this.free); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateShortRunningFreeCommand.java b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateShortRunningFreeCommand.java new file mode 100644 index 000000000000..0f7e295d8845 --- /dev/null +++ b/connector/src/main/java/org/jboss/as/connector/services/workmanager/transport/UpdateShortRunningFreeCommand.java @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.connector.services.workmanager.transport; + +import org.jboss.jca.core.spi.workmanager.Address; +import org.wildfly.clustering.dispatcher.Command; + +/** + * Equivalent to {@link org.jboss.jca.core.workmanager.transport.remote.jgroups.JGroupsTransport#updateShortRunningFree(java.util.Map, Long)}. + * @author Paul Ferraro + */ +public class UpdateShortRunningFreeCommand implements Command { + private static final long serialVersionUID = -3887902059566674034L; + + private final Address address; + private final long free; + + public UpdateShortRunningFreeCommand(Address address, long free) { + this.address = address; + this.free = free; + } + + @Override + public Void execute(CommandDispatcherTransport transport) { + transport.localUpdateShortRunningFree(this.address, this.free); + return null; + } +} diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java index 260db1c5da1e..11263bc08aa6 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/DistributedWorkManagerAdd.java @@ -56,8 +56,8 @@ import org.jboss.msc.service.ServiceBuilder; import org.jboss.msc.service.ServiceController; import org.jboss.msc.service.ServiceTarget; -import org.wildfly.clustering.jgroups.spi.ChannelFactory; -import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; +import org.wildfly.clustering.dispatcher.CommandDispatcherFactory; +import org.wildfly.clustering.spi.ClusteringDefaultRequirement; /** * @author Jesper Pedersen @@ -148,7 +148,7 @@ protected void performRuntime(final OperationContext context, final ModelNode op DistributedWorkManagerService wmService = new DistributedWorkManagerService(namedDistributedWorkManager); ServiceBuilder builder = serviceTarget .addService(ConnectorServices.WORKMANAGER_SERVICE.append(name), wmService); - builder.addDependency(JGroupsDefaultRequirement.CHANNEL_FACTORY.getServiceName(context), ChannelFactory.class, wmService.getJGroupsChannelFactoryInjector()); + builder.addDependency(ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getServiceName(context), CommandDispatcherFactory.class, wmService.getCommandDispatcherFactoryInjector()); builder.addDependency(ServiceBuilder.DependencyType.OPTIONAL, ThreadsServices.EXECUTOR.append(WORKMANAGER_LONG_RUNNING).append(name), Executor.class, wmService.getExecutorLongInjector()); builder.addDependency(ThreadsServices.EXECUTOR.append(WORKMANAGER_SHORT_RUNNING).append(name), Executor.class, wmService.getExecutorShortInjector()); diff --git a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java index 989772cf50bc..105794eceee2 100644 --- a/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java +++ b/connector/src/main/java/org/jboss/as/connector/subsystems/jca/JcaDistributedWorkManagerDefinition.java @@ -43,7 +43,7 @@ import org.jboss.as.controller.registry.ManagementResourceRegistration; import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelType; -import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; +import org.wildfly.clustering.spi.ClusteringDefaultRequirement; /** * @author Tomaz Cerar (c) 2012 Red Hat Inc. @@ -167,7 +167,7 @@ public AttributeDefinition getAttribute() { } enum DWmCapabilities { - CHANNEL_FACTORY(RuntimeCapability.Builder.of("org.wildfly.connector.workmanager").addRequirements(JGroupsDefaultRequirement.CHANNEL_FACTORY.getName()).build()); + CHANNEL_FACTORY(RuntimeCapability.Builder.of("org.wildfly.connector.workmanager").addRequirements(ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getName()).build()); private final RuntimeCapability capability; diff --git a/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java b/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java index 133d79d16aca..a31e614b50d2 100644 --- a/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java +++ b/connector/src/test/java/org/jboss/as/connector/subsystems/jca/JcaSubsystemTestCase.java @@ -46,7 +46,7 @@ import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; -import org.wildfly.clustering.jgroups.spi.JGroupsDefaultRequirement; +import org.wildfly.clustering.spi.ClusteringDefaultRequirement; /** * @author Kabir Khan @@ -83,7 +83,7 @@ public void testSchemaOfSubsystemTemplates() throws Exception { @Override protected AdditionalInitialization createAdditionalInitialization() { - return AdditionalInitialization.withCapabilities(JGroupsDefaultRequirement.CHANNEL_FACTORY.getName()); + return AdditionalInitialization.withCapabilities(ClusteringDefaultRequirement.COMMAND_DISPATCHER_FACTORY.getName()); } @Test diff --git a/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/connector/main/module.xml b/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/connector/main/module.xml index bd6649b78ece..28caa8aa1fa3 100644 --- a/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/connector/main/module.xml +++ b/feature-pack/src/main/resources/modules/system/layers/base/org/jboss/as/connector/main/module.xml @@ -70,9 +70,10 @@ - - - + + + +