use of org.apache.rya.accumulo.mr.merge.common.InstanceType in project incubator-rya by apache.
the class CopyTool method createChildInstance.
private Instance createChildInstance(final Configuration config) throws Exception {
Instance instance = null;
String instanceTypeProp = config.get(CREATE_CHILD_INSTANCE_TYPE_PROP);
final String childAuth = config.get(MRUtils.AC_AUTH_PROP + MergeTool.CHILD_SUFFIX);
// Default to distribution cluster if not specified
if (StringUtils.isBlank(instanceTypeProp)) {
instanceTypeProp = InstanceType.DISTRIBUTION.toString();
}
final InstanceType instanceType = InstanceType.fromName(instanceTypeProp);
switch(instanceType) {
case DISTRIBUTION:
if (childInstance == null) {
throw new IllegalArgumentException("Must specify instance name for distributed mode");
} else if (childZk == null) {
throw new IllegalArgumentException("Must specify ZooKeeper hosts for distributed mode");
}
instance = new ZooKeeperInstance(childInstance, childZk);
break;
case MINI:
childAccumuloInstanceDriver = new AccumuloInstanceDriver("Child", false, true, false, false, childUserName, childPwd, childInstance, childTablePrefix, childAuth);
childAccumuloInstanceDriver.setUpInstance();
childAccumuloInstanceDriver.setUpTables();
childZk = childAccumuloInstanceDriver.getZooKeepers();
MergeTool.setDuplicateKeysForProperty(config, MRUtils.AC_ZK_PROP + MergeTool.CHILD_SUFFIX, childZk);
instance = new ZooKeeperInstance(childInstance, childZk);
break;
case MOCK:
instance = new MockInstance(childInstance);
break;
default:
throw new AccumuloException("Unexpected instance type: " + instanceType);
}
return instance;
}
Aggregations