Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2011 Red Hat Inc. and/or its affiliates and other contributors
   * as indicated by the @authors tag. All rights reserved.
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
  * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * 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,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  */
 package org.jboss.as.host.controller.mgmt;
 
 import static org.jboss.as.host.controller.HostControllerMessages.MESSAGES;
 import static org.jboss.as.process.protocol.ProtocolUtils.expectHeader;
 
 import java.io.File;
 
Handles for requests from slave DC to master DC on the 'domain' channel.

Author(s):
Kabir Khan
 
 
     private final DomainController domainController;
     private final Executor asyncExecutor;
 
     public MasterDomainControllerOperationHandlerImpl(final DomainController domainControllerfinal Executor asyncExecutor) {
         this. = domainController;
         this. = asyncExecutor;
     }
 
     @Override
         final byte operationId = header.getOperationId();
         switch (operationId) {
                 handlers.registerActiveOperation(header.getBatchId(), null);
                 return new UnregisterOperation();
             } case .: {
                 handlers.registerActiveOperation(header.getBatchId(), null);
                 return new GetFileOperation();
             }
         }
         return handlers.resolveNext();
     }
 
     private class UnregisterOperation extends AbstractHostRequestHandler {
 
         @Override
         void handleRequest(String hostIdDataInput inputManagementRequestContext<Voidcontextthrows IOException {
             .unregisterRemoteHost(hostIdnull);
             final FlushableDataOutput os = writeGenericResponseHeader(context);
             try {
                 os.write(.);
                 os.close();
             } finally {
                 StreamUtils.safeClose(os);
             }
         }
 
     }
 
     private class GetFileOperation extends AbstractHostRequestHandler {
 
 
         @Override
         void handleRequest(String hostIdDataInput inputManagementRequestContext<Voidcontextthrows IOException {
             final RootFileReader reader = new RootFileReader() {
                 public File readRootFile(byte rootIdString filePaththrows RequestProcessingException {
                     final HostFileRepository localFileRepository = .getLocalFileRepository();
                    switch (rootId) {
                        case .: {
                            return localFileRepository.getFile(filePath);
                        }
                        case .: {
                            return localFileRepository.getConfigurationFile(filePath);
                        }
                        case .: {
                            byte[] hash = HashUtil.hexStringToByteArray(filePath);
                            return localFileRepository.getDeploymentRoot(hash);
                        }
                        default: {
                            throw .invalidRootId(rootId);
                        }
                    }
                }
            };
            .handleRequest(inputreadercontext);
        }
    }
    abstract static class AbstractHostRequestHandler implements ManagementRequestHandler<ModelNodeVoid> {
        abstract void handleRequest(final String hostIdDataInput inputManagementRequestContext<Voidcontextthrows IOException;
        @Override
        public void handleRequest(DataInput inputActiveOperation.ResultHandler<ModelNoderesultHandlerManagementRequestContext<Voidcontextthrows IOException {
            expectHeader(input.);
            final String hostId = input.readUTF();
            handleRequest(hostIdinputcontext);
            resultHandler.done(null);
        }
        protected FlushableDataOutput writeGenericResponseHeader(final ManagementRequestContext<Voidcontextthrows IOException {
            final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader());
            return context.writeMessage(header);
        }
    }
New to GrepCode? Check out our FAQ X