use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project beam by apache.
the class Twister2Runner method setupSystem.
private void setupSystem(Twister2PipelineOptions options) {
prepareFilesToStage(options);
zipFilesToStage(options);
System.setProperty("cluster_type", options.getClusterType());
System.setProperty("job_file", options.getJobFileZip());
System.setProperty("job_type", options.getJobType());
if (isLocalMode(options)) {
System.setProperty("twister2_home", System.getProperty("java.io.tmpdir"));
System.setProperty("config_dir", System.getProperty("java.io.tmpdir") + "/conf/");
} else {
System.setProperty("twister2_home", options.getTwister2Home());
System.setProperty("config_dir", options.getTwister2Home() + "/conf/");
// do a simple config dir validation
File cDir = new File(System.getProperty("config_dir"), options.getClusterType());
String[] filesList = new String[] { "core.yaml", "network.yaml", "data.yaml", "resource.yaml", "task.yaml" };
for (String file : filesList) {
File toCheck = new File(cDir, file);
if (!toCheck.exists()) {
throw new Twister2RuntimeException("Couldn't find " + file + " in config directory specified.");
}
}
// setup logging
FileInputStream fis = null;
try {
fis = new FileInputStream(new File(cDir, "logger.properties"));
LogManager.getLogManager().readConfiguration(fis);
fis.close();
} catch (IOException e) {
LOG.warning("Couldn't load logging configuration");
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
LOG.info(e.getMessage());
}
}
}
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKEventsManager method initEventCounter.
public static void initEventCounter(CuratorFramework client, String rootPath, String jobID) {
String eventsDir = ZKUtils.eventsDir(rootPath, jobID);
try {
eventCounter = client.getChildren().forPath(eventsDir).size();
LOG.info("eventCounter is set to: " + eventCounter);
} catch (Exception e) {
throw new Twister2RuntimeException("Could not get children of events directory: " + eventsDir, e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class TCPChannel method iSend.
/**
* Send a buffer
* @param buffer buffer
* @param size size of the buffer, we assume start from 0th position
* @param workerID the worker id
* @param edge the edg
* @return the reference message created
*/
public TCPMessage iSend(ByteBuffer buffer, int size, int workerID, int edge) {
SocketChannel ch = clientChannels.get(workerID);
if (ch == null) {
throw new Twister2RuntimeException("Can not send to an un-connected worker: " + workerID);
}
Client client = clients.get(workerID);
return client.send(ch, buffer, size, edge);
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class RowSchema method toArrowSchema.
public org.apache.arrow.vector.types.pojo.Schema toArrowSchema() {
List<Field> fields = new ArrayList<>();
for (TField f : types) {
Field field;
if (f.getType().equals(MessageTypes.INTEGER)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(32, true), null), null);
} else if (f.getType().equals(MessageTypes.LONG)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(64, true), null), null);
} else if (f.getType().equals(MessageTypes.SHORT)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.Int(16, true), null), null);
} else if (f.getType().equals(MessageTypes.FLOAT)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null), null);
} else if (f.getType().equals(MessageTypes.DOUBLE)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), null), null);
} else if (f.getType().equals(MessageTypes.STRING)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.Binary(), null), null);
} else if (f.getType().equals(MessageTypes.BYTE)) {
field = new Field(f.getName(), new FieldType(false, new ArrowType.Binary(), null), null);
} else {
throw new Twister2RuntimeException("Un-known type");
}
fields.add(field);
}
return new org.apache.arrow.vector.types.pojo.Schema(fields);
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKPersStateManager method updateJobMasterStatus.
/**
* update jm status at ZK
*/
public static void updateJobMasterStatus(CuratorFramework client, String rootPath, String jobID, String jmAddress, JobMasterState state) {
String jmPersPath = ZKUtils.jmPersPath(rootPath, jobID);
try {
byte[] znodeBody = ZKUtils.encodeJobMasterZnode(jmAddress, state.getNumber());
client.setData().forPath(jmPersPath, znodeBody);
} catch (Exception e) {
throw new Twister2RuntimeException("Can not update job master pers state znode.", e);
}
}
Aggregations