use of org.apache.helix.manager.zk.ByteArraySerializer in project helix by apache.
the class ZkCopy method main.
public static void main(String[] args) throws Exception {
CommandLineParser cliParser = new GnuParser();
Options cliOptions = constructCmdLineOpt();
CommandLine cmd = null;
try {
cmd = cliParser.parse(cliOptions, args);
} catch (ParseException pe) {
System.err.println("CommandLineClient: failed to parse command-line options: " + pe.toString());
printUsage(cliOptions);
System.exit(1);
}
URI srcUri = new URI(cmd.getOptionValue(src));
URI dstUri = new URI(cmd.getOptionValue(dst));
ZkCopyScheme srcScheme = ZkCopyScheme.valueOf(srcUri.getScheme());
ZkCopyScheme dstScheme = ZkCopyScheme.valueOf(dstUri.getScheme());
if (srcScheme == ZkCopyScheme.zk && dstScheme == ZkCopyScheme.zk) {
String srcZkAddr = srcUri.getAuthority();
String dstZkAddr = dstUri.getAuthority();
ZkClient srcClient = null;
ZkClient dstClient = null;
try {
if (srcZkAddr.equals(dstZkAddr)) {
srcClient = dstClient = new ZkClient(srcZkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
} else {
srcClient = new ZkClient(srcZkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
dstClient = new ZkClient(dstZkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
}
String srcPath = srcUri.getPath();
String dstPath = dstUri.getPath();
zkCopy(srcClient, srcPath, dstClient, dstPath);
} finally {
if (srcClient != null) {
srcClient.close();
}
if (dstClient != null) {
dstClient.close();
}
}
} else {
System.err.println("Unsupported scheme. srcScheme: " + srcScheme + ", dstScheme: " + dstScheme);
System.exit(1);
}
}
use of org.apache.helix.manager.zk.ByteArraySerializer in project helix by apache.
the class HelixAdminWebApp method start.
public synchronized void start() throws Exception {
LOG.info("helixAdminWebApp starting");
if (_component == null) {
_zkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
_rawZkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
_component = new Component();
_component.getServers().add(Protocol.HTTP, _helixAdminPort);
Context applicationContext = _component.getContext().createChildContext();
applicationContext.getAttributes().put(RestAdminApplication.ZKSERVERADDRESS, _zkServerAddress);
applicationContext.getAttributes().put(RestAdminApplication.PORT, "" + _helixAdminPort);
applicationContext.getAttributes().put(RestAdminApplication.ZKCLIENT, _zkClient);
applicationContext.getAttributes().put(ResourceUtil.ContextKey.RAW_ZKCLIENT.toString(), _rawZkClient);
_adminApp = new RestAdminApplication(applicationContext);
// Attach the application to the component and start it
_component.getDefaultHost().attach(_adminApp);
_component.start();
}
LOG.info("helixAdminWebApp started on port: " + _helixAdminPort);
}
Aggregations