use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKBarrierManager method createBarrierDir.
/**
* create parent directory for barrier
*/
public static void createBarrierDir(CuratorFramework client, String barrierDirPath) {
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(barrierDirPath);
LOG.info("BarrierDirectory created: " + barrierDirPath);
} catch (Exception e) {
throw new Twister2RuntimeException("BarrierDirectory can not be created for the path: " + barrierDirPath, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKEphemStateManager method createEphemDir.
/**
* create parent directory for ephemeral worker znodes
*/
public static void createEphemDir(CuratorFramework client, String rootPath, String jobID) {
String ephemDirPath = ZKUtils.ephemDir(rootPath, jobID);
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(ephemDirPath);
LOG.info("Job EphemStateDir created: " + ephemDirPath);
} catch (Exception e) {
throw new Twister2RuntimeException("EphemStateDir can not be created for the path: " + ephemDirPath, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKEventsManager method createEventsZNode.
/**
* Create job znode for persistent states
* Assumes that there is no znode exists in the ZooKeeper
* This method should be called by the submitting client
*/
public static void createEventsZNode(CuratorFramework client, String rootPath, String jobID) {
String eventsDir = ZKUtils.eventsDir(rootPath, jobID);
try {
client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(eventsDir);
LOG.info("Job EventsZnode created: " + eventsDir);
} catch (Exception e) {
throw new Twister2RuntimeException("EventsZnode can not be created for the path: " + eventsDir, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class RowSchema method fromArrow.
public static RowSchema fromArrow(org.apache.arrow.vector.types.pojo.Schema schema) {
List<Field> fields = schema.getFields();
List<TField> tFields = new ArrayList<>();
for (Field f : fields) {
TField tField;
if (f.getFieldType().equals(ArrowTypes.INT_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.INTEGER);
} else if (f.getFieldType().equals(ArrowTypes.LONG_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.LONG);
} else if (f.getFieldType().equals(ArrowTypes.SHORT_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.SHORT);
} else if (f.getFieldType().equals(ArrowTypes.FLOAT_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.FLOAT);
} else if (f.getFieldType().equals(ArrowTypes.DOUBLE_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.DOUBLE);
} else if (f.getFieldType().equals(ArrowTypes.STRING_FIELD_TYPE)) {
tField = new TField(f.getName(), MessageTypes.STRING);
} else if (f.getFieldType().equals(ArrowTypes.BINARY_FILED_TYPE)) {
tField = new TField(f.getName(), MessageTypes.BYTE);
} else {
throw new Twister2RuntimeException("Unknown type");
}
tFields.add(tField);
}
return new RowSchema(tFields);
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class K8sWorkerUtils method initRestartFromCM.
/**
* get restartCount from a ConfigMap in K8s master
* if the worker/jm is starting for the first time,
* we need to add the config restart count key to the config map
* otherwise, we need to increase the restart count at the configmap
* <p>
* restartCount is returned as zero if the worker/jm is starting for the first time,
* if it is more than zero, the worker is restarting
*/
public static int initRestartFromCM(KubernetesController controller, String jbID, String keyName) {
int restartCount = controller.getRestartCount(jbID, keyName);
// increase the count by 1 for the new value
restartCount++;
// add the key to configmap and set its value as zero
if (restartCount == 0) {
boolean added = controller.addConfigMapParam(jbID, keyName, 0 + "");
if (!added) {
throw new Twister2RuntimeException("Could not add the restartCount to ConfigMap");
}
// if restartCount is more than 0 after the increase, the worker has started before,
// it is coming from failure, set new count
} else if (restartCount > 0) {
boolean updated = controller.updateConfigMapParam(jbID, keyName, restartCount + "");
if (!updated) {
throw new Twister2RuntimeException("Could not update the restartCount in ConfigMap");
}
}
return restartCount;
}
Aggregations