use of org.apache.helix.ConfigAccessor in project helix by apache.
the class TaskCluster method submitDag.
public void submitDag(Dag dag) throws Exception {
ConfigAccessor clusterConfig = new ConfigAccessor(_zkclient);
HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(_clusterName).build();
for (String id : dag.getNodeIds()) {
Dag.Node node = dag.getNode(id);
clusterConfig.set(clusterScope, node.getId(), node.toJson());
_admin.addResource(_clusterName, node.getId(), node.getNumPartitions(), DEFAULT_STATE_MODEL, RebalanceMode.FULL_AUTO.toString());
}
for (String id : dag.getNodeIds()) {
_admin.rebalance(_clusterName, id, 1);
}
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class TaskStateModel method onBecomeOnlineFromOffline.
@Transition(to = "ONLINE", from = "OFFLINE")
public void onBecomeOnlineFromOffline(Message message, NotificationContext context) throws Exception {
LOG.debug(_workerId + " becomes ONLINE from OFFLINE for " + _partition);
ConfigAccessor clusterConfig = context.getManager().getConfigAccessor();
HelixManager manager = context.getManager();
HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(manager.getClusterName()).build();
String json = clusterConfig.get(clusterScope, message.getResourceName());
Dag.Node node = Dag.Node.fromJson(json);
Set<String> parentIds = node.getParentIds();
String resourceName = message.getResourceName();
int numPartitions = node.getNumPartitions();
Task task = _taskFactory.createTask(resourceName, parentIds, manager, _taskResultStore);
manager.addExternalViewChangeListener(task);
LOG.debug("Starting task for " + _partition + "...");
int partitionNum = Integer.parseInt(_partition.split("_")[1]);
task.execute(resourceName, numPartitions, partitionNum);
LOG.debug("Task for " + _partition + " done");
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class AbstractTestClass method beforeSuite.
@BeforeSuite
public void beforeSuite() throws Exception {
if (!_init) {
// TODO: use logging.properties file to config java.util.logging.Logger levels
java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
topJavaLogger.setLevel(Level.WARNING);
_gZkClient = new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT, ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
_gZkClientTestNS = new ZkClient(_zkAddrTestNS, ZkClient.DEFAULT_CONNECTION_TIMEOUT, ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
_gSetupTool = new ClusterSetup(_gZkClient);
_configAccessor = new ConfigAccessor(_gZkClient);
_baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
_baseAccessorTestNS = new ZkBaseDataAccessor<>(_gZkClientTestNS);
// wait for the web service to start
Thread.sleep(100);
setup();
_init = true;
}
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class ClusterAccessor method getClusterConfig.
@GET
@Path("{clusterId}/configs")
public Response getClusterConfig(@PathParam("clusterId") String clusterId) {
ConfigAccessor accessor = getConfigAccessor();
ClusterConfig config = null;
try {
config = accessor.getClusterConfig(clusterId);
} catch (HelixException ex) {
// cluster not found.
_logger.info("Failed to get cluster config for cluster " + clusterId + ", cluster not found, Exception: " + ex);
} catch (Exception ex) {
_logger.error("Failed to get cluster config for cluster " + clusterId + " Exception: " + ex);
return serverError(ex);
}
if (config == null) {
return notFound();
}
return JSONRepresentation(config.getRecord());
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class ResourceAccessor method getResourceConfig.
@GET
@Path("{resourceName}/configs")
public Response getResourceConfig(@PathParam("clusterId") String clusterId, @PathParam("resourceName") String resourceName) {
ConfigAccessor accessor = getConfigAccessor();
ResourceConfig resourceConfig = accessor.getResourceConfig(clusterId, resourceName);
if (resourceConfig != null) {
return JSONRepresentation(resourceConfig.getRecord());
}
return notFound();
}
Aggregations