Skip to content

Commit

Permalink
[AS7-4456] improved error handling on remote HC registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuel Muckenhuber authored and bstansberry committed Apr 30, 2012
1 parent cf0c640 commit 7d82e57
Show file tree
Hide file tree
Showing 17 changed files with 293 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
public interface ProxyOperationAddressTranslator {
PathAddress translateAddress(PathAddress address);

ProxyOperationAddressTranslator NOOP = new ProxyOperationAddressTranslator() {
@Override
public PathAddress translateAddress(PathAddress address) {
return address;
}
};

ProxyOperationAddressTranslator SERVER = new ProxyOperationAddressTranslator() {
public PathAddress translateAddress(PathAddress address) {
PathAddress translated = address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public static RemoteProxyController create(final TransactionalProtocolClient cli
* @return the proxy controller
*/
public static RemoteProxyController create(final ManagementChannelHandler channelAssociation, final PathAddress pathAddress, final ProxyOperationAddressTranslator addressTranslator) {
// Create the protocol client here for now
final TransactionalProtocolClientImpl client = new TransactionalProtocolClientImpl(channelAssociation);
channelAssociation.addHandlerFactory(client);
final TransactionalProtocolClient client = TransactionalProtocolHandlers.createClient(channelAssociation);
// the remote proxy
return create(client, pathAddress, addressTranslator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@
package org.jboss.as.controller.remote;

import org.jboss.as.controller.ModelController;
import org.jboss.as.controller.client.OperationAttachments;
import org.jboss.as.controller.client.OperationMessageHandler;
import org.jboss.as.protocol.mgmt.ManagementChannelAssociation;
import org.jboss.as.protocol.mgmt.ManagementChannelHandler;
import org.jboss.as.protocol.mgmt.ManagementRequestHandlerFactory;
import org.jboss.dmr.ModelNode;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
* @author Emanuel Muckenhuber
Expand All @@ -43,6 +36,18 @@ private TransactionalProtocolHandlers() {
//
}

/**
* Create a transactional protocol client.
*
* @param channelAssociation the channel handler
* @return the transactional protocol client
*/
public static TransactionalProtocolClient createClient(final ManagementChannelHandler channelAssociation) {
final TransactionalProtocolClientImpl client = new TransactionalProtocolClientImpl(channelAssociation);
channelAssociation.addHandlerFactory(client);
return client;
}

/**
* Add a transaction protocol request handler to an existing channel.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ public static TransformationContext getTransformationContext(OperationContext co
return new TransformersImpl.DelegateTransformContext(context);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,9 @@ TransactionalProtocolClient createClient() throws Exception {
TransactionalProtocolClient createClient(final Channel channel) {
channels.add(channel);
final ManagementChannelHandler channelAssociation = new ManagementChannelHandler(channel, clientExecutor);
final TransactionalProtocolClientImpl handler = new TransactionalProtocolClientImpl(channelAssociation);
channelAssociation.addHandlerFactory(handler);
final TransactionalProtocolClient client = TransactionalProtocolHandlers.createClient(channelAssociation);
channel.receiveMessage(channelAssociation.getReceiver());
return handler;
return client;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ private void writeFile(final File localPath, final File file, final FlushableDat
}
}
output.writeByte(protocol.fileEnd());
output.flush();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STEPS;
import org.jboss.as.controller.remote.RemoteProxyController;
import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.controller.transform.Transformers;
import static org.jboss.as.domain.controller.DomainControllerLogger.HOST_CONTROLLER_LOGGER;
import static org.jboss.as.domain.controller.DomainControllerMessages.MESSAGES;

Expand All @@ -65,6 +66,7 @@
import org.jboss.as.domain.controller.ServerIdentity;
import org.jboss.as.domain.controller.plan.RolloutPlanController;
import org.jboss.as.domain.controller.plan.ServerTaskExecutor;
import org.jboss.as.host.controller.mgmt.TransformingProxyController;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;

Expand Down Expand Up @@ -244,9 +246,9 @@ protected boolean execute(TransactionalProtocolClient.TransactionalOperationList
return false;
}
}
final RemoteProxyController remoteProxyController = (RemoteProxyController) proxy;
final ModelNode transformedOperation = remoteProxyController.translateOperationForProxy(original);
final TransactionalProtocolClient client = remoteProxyController.getTransactionalProtocolClient();
final TransformingProxyController remoteProxyController = (TransformingProxyController) proxy;
final ModelNode transformedOperation = remoteProxyController.getTransformers().transformOperation(Transformers.Factory.getTransformationContext(context), original);
final TransactionalProtocolClient client = remoteProxyController.getProtocolClient();
return executeOperation(listener, client, server, transformedOperation);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.ProxyController;
import static org.jboss.as.domain.controller.DomainControllerMessages.MESSAGES;
import org.jboss.as.host.controller.mgmt.TransformingProxyController;
import org.jboss.dmr.ModelNode;
import org.jboss.threads.AsyncFuture;

Expand Down Expand Up @@ -83,7 +84,7 @@ public void execute(final OperationContext context, final ModelNode operation) t
for (Map.Entry<String, ProxyController> entry : hostProxies.entrySet()) {
// Create the proxy task
final String host = entry.getKey();
final TransactionalProtocolClient client = ((RemoteProxyController)entry.getValue()).getTransactionalProtocolClient();
final TransactionalProtocolClient client = ((TransformingProxyController)entry.getValue()).getProtocolClient();
final HostControllerUpdateTask task = new HostControllerUpdateTask(host, operation.clone(), context, client);
// Execute the operation on the remote host
final AsyncFuture<ModelNode> finalResult = task.execute(listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CANCELLED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.domain.controller.DomainControllerLogger;
import org.jboss.as.domain.controller.ServerIdentity;
import org.jboss.dmr.ModelNode;

Expand Down Expand Up @@ -52,7 +53,11 @@ public AbstractServerGroupRolloutTask(List<ServerUpdateTask> tasks, ServerUpdate

@Override
public void run() {
execute();
try {
execute();
} catch (Throwable t) {
DomainControllerLogger.ROOT_LOGGER.debugf(t, "failed to process task %s", tasks.iterator().next().getOperation());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HOST;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RUNNING_SERVER;

import org.jboss.as.controller.remote.RemoteProxyController;
import static org.jboss.as.host.controller.HostControllerLogger.ROOT_LOGGER;

import org.jboss.as.host.controller.mgmt.TransformingProxyController;
import org.jboss.as.network.NetworkUtils;
import org.jboss.as.process.ProcessControllerClient;
import org.jboss.as.protocol.mgmt.ManagementChannelHandler;
Expand Down Expand Up @@ -111,7 +111,7 @@ public static String getServerName(String serverProcessName) {
private final ProcessControllerClient processControllerClient;
private final ManagedServer.ManagedServerBootConfiguration bootConfiguration;

private volatile RemoteProxyController proxyController;
private volatile TransformingProxyController proxyController;

private volatile InternalState requiredState = InternalState.STOPPED;
private volatile InternalState internalState = InternalState.STOPPED;
Expand Down Expand Up @@ -267,22 +267,16 @@ protected void processStarted() {
finishTransition(InternalState.PROCESS_STARTING, InternalState.PROCESS_STARTED);
}

/**
*
* @param channelAssociation
* @return
*/
protected synchronized RemoteProxyController channelRegistered(final ManagementChannelHandler channelAssociation) {
protected synchronized void channelRegistered(final ManagementChannelHandler channelAssociation) {
internalSetState(new TransitionTask() {
@Override
public void execute(final ManagedServer server) throws Exception {
server.proxyController = RemoteProxyController.create(channelAssociation,
server.proxyController = TransformingProxyController.Factory.create(channelAssociation,
PathAddress.pathAddress(PathElement.pathElement(HOST, hostControllerName), serverPath),
ProxyOperationAddressTranslator.SERVER);
}
// TODO we just check that we are in the correct state, perhaps introduce a new state
}, InternalState.SERVER_STARTING, InternalState.SERVER_STARTING);
return proxyController;
}

protected synchronized void serverStarted(final TransitionTask task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void handleClose(final Channel closed, final IOException exception) {
result = channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get();
} catch (Exception e) {
if(e.getCause() instanceof IOException) {
throw (IOException) e;
throw (IOException) e.getCause();
}
throw new IOException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.RemotingOptions;
import org.jboss.threads.AsyncFuture;
import org.jboss.threads.AsyncFutureTask;
import org.jboss.threads.JBossThreadFactory;
import org.xnio.OptionMap;

/**
* Establishes the connection from a slave {@link org.jboss.as.domain.controller.DomainController} to the master
Expand Down Expand Up @@ -267,14 +269,15 @@ public synchronized void start(StartContext context) throws StartException {
final RemoteDomainConnection connection;
final ManagementChannelHandler handler;
try {

// Include additional local host information when registering at the DC
final ModelNode hostInfo = createLocalHostHostInfo(localHostInfo, productConfig);
final OptionMap options = OptionMap.EMPTY;

// Gather the required information to connect to the remote DC
final ProtocolChannelClient.Configuration configuration = new ProtocolChannelClient.Configuration();
configuration.setUri(new URI("remote://" + NetworkUtils.formatPossibleIpv6Address(localHostInfo.getRemoteDomainControllerHost()) + ":" + localHostInfo.getRemoteDomainControllerPort()));
configuration.setEndpoint(endpointInjector.getValue());
configuration.setOptionMap(options);

final SecurityRealm realm = securityRealmInjector.getOptionalValue();
// Create the remote domain channel strategy
Expand Down
Loading

0 comments on commit 7d82e57

Please sign in to comment.