/** * Switch state from WRITE to READ */ @Override public void switchState() { this.state = State.READ; try { this.outputStream.flush(); } catch (IOException e) { throw new GuaguaRuntimeException(e); } }
private String getLocalHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
private String getLocalHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
private static String getLocalHostName() { // TODO use cache?? try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
private String getLocalHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
private String getLocalHostName() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
/** * Constructor with file name in current working dir. */ public DiskList(String fileName) { try { this.file = new File(fileName); this.outputStream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); this.inputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); } catch (FileNotFoundException e) { throw new GuaguaRuntimeException(e); } }
@Override public void postApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) { if(this.isNeedStartZookeeper) { try { this.fileSystem.delete(new Path(this.getZookeeperServerFolder(context)), true); } catch (IOException e) { throw new GuaguaRuntimeException(e); } } }
@Override public void postApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) { if(this.isNeedStartZookeeper) { try { this.fileSystem.delete(new Path(this.getZookeeperServerFolder(context)), true); } catch (IOException e) { throw new GuaguaRuntimeException(e); } } }
@Override public void postApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) { if(this.isNeedStartZookeeper) { try { this.fileSystem.delete(new Path(this.getZookeeperServerFolder(context)), true); } catch (IOException e) { throw new GuaguaRuntimeException(e); } } }
@Override public void postApplication(MasterContext<MASTER_RESULT, WORKER_RESULT> context) { if(this.isNeedStartZookeeper) { try { this.fileSystem.delete(new Path(this.getZookeeperServerFolder(context)), true); } catch (IOException e) { throw new GuaguaRuntimeException(e); } } }
@Override public boolean nextKeyValue() throws IOException { try { return this.parquetRecordReader.nextKeyValue(); } catch (InterruptedException e) { throw new GuaguaRuntimeException(e); } }
/** * Re-open stream for iterators. */ public void reOpen() { close(); try { this.inputStream = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); } catch (FileNotFoundException e) { throw new GuaguaRuntimeException(e); } }
@Override public void execute() { try { doExecute(); } catch (InterruptedException e) { // transfer interrupt state to caller thread. Thread.currentThread().interrupt(); } catch (Exception e) { throw new GuaguaRuntimeException(e); } }
/** * Re-open stream for iterators. */ public void reOpen() { close(); try { this.inputStream = new DataInputStream(new FileInputStream(file)); } catch (FileNotFoundException e) { throw new GuaguaRuntimeException(e); } }
@Override public GuaguaWritableAdapter<Tuple> getCurrentValue() { try { return new GuaguaWritableAdapter<Tuple>(this.parquetRecordReader.getCurrentValue()); } catch (IOException e) { throw new GuaguaRuntimeException(e); } catch (InterruptedException e) { throw new GuaguaRuntimeException(e); } }
@SuppressWarnings("unchecked") private WorkerComputable<MASTER_RESULT, WORKER_RESULT> newWorkerComputable() { WorkerComputable<MASTER_RESULT, WORKER_RESULT> workerComputable; try { workerComputable = ((WorkerComputable<MASTER_RESULT, WORKER_RESULT>) ReflectionUtils.newInstance(Class .forName(this.getProps().get(GuaguaConstants.WORKER_COMPUTABLE_CLASS).toString()))); } catch (ClassNotFoundException e) { throw new GuaguaRuntimeException(e); } return workerComputable; }
@SuppressWarnings("unchecked") private MasterComputable<MASTER_RESULT, WORKER_RESULT> newMasterComputable() { MasterComputable<MASTER_RESULT, WORKER_RESULT> masterComputable; try { masterComputable = (MasterComputable<MASTER_RESULT, WORKER_RESULT>) ReflectionUtils.newInstance(Class .forName(this.getProps().get(GuaguaConstants.MASTER_COMPUTABLE_CLASS).toString())); } catch (ClassNotFoundException e) { throw new GuaguaRuntimeException(e); } return masterComputable; }
private static void killJob(Configuration conf, String jobIdStr, String reason) { LOG.info(reason); // "Kill job because of master is already finished try { org.apache.hadoop.mapred.JobClient jobClient = new org.apache.hadoop.mapred.JobClient( (org.apache.hadoop.mapred.JobConf) conf); JobID jobId = JobID.forName(jobIdStr); RunningJob job = jobClient.getJob(jobId); job.killJob(); } catch (IOException ioe) { throw new GuaguaRuntimeException(ioe); } }
@Override public void initialize(GuaguaFileSplit split) throws IOException { ReadSupport<Tuple> readSupport = getReadSupportInstance(this.conf); this.parquetRecordReader = new ParquetRecordReader<Tuple>(readSupport, getFilter(this.conf)); ParquetInputSplit parquetInputSplit = new ParquetInputSplit(new Path(split.getPath()), split.getOffset(), split.getOffset() + split.getLength(), split.getLength(), null, null); try { this.parquetRecordReader.initialize(parquetInputSplit, buildContext()); } catch (InterruptedException e) { throw new GuaguaRuntimeException(e); } }