try { stream = fileContext.create(lPath, EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE), Options.CreateOpts.CreateParent.createParent()); store(stream, object); stateSaved = true;
private DataOutputStream getOutputStream(FileSystemWALPointer pointer) throws IOException { Preconditions.checkArgument(outputStream == null, "output stream is not null"); if (pointer.offset > 0 && (fileSystemWAL.fileContext.getDefaultFileSystem() instanceof LocalFs || fileSystemWAL.fileContext.getDefaultFileSystem() instanceof RawLocalFs)) { //On local file system the stream is always closed and never flushed so we open it again in append mode if the //offset > 0. This block is entered only when appending to wal while writing on local fs. return fileSystemWAL.fileContext.create(new Path(fileSystemWAL.tempPartFiles.get(pointer.partNum)), EnumSet.of(CreateFlag.CREATE, CreateFlag.APPEND), Options.CreateOpts.CreateParent.createParent()); } String partFile = fileSystemWAL.getPartFilePath(pointer.partNum); String tmpFilePath = createTmpFilePath(partFile); fileSystemWAL.tempPartFiles.put(pointer.partNum, tmpFilePath); Preconditions.checkArgument(pointer.offset == 0, "offset > 0"); LOG.debug("open {} => {}", pointer.partNum, tmpFilePath); outputStream = fileSystemWAL.fileContext.create(new Path(tmpFilePath), EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE), Options.CreateOpts.CreateParent.createParent()); return outputStream; }
try { stream = fileContext.create(lPath, EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE), Options.CreateOpts.CreateParent.createParent()); InputStream in = null; try {
EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE), Options.CreateOpts.CreateParent.createParent());
/** * This method is for saving meta information about this application in HDFS -- the meta information that generally * does not change across multiple attempts */ private void saveMetaInfo() throws IOException { Path file = new Path(this.vars.appPath, APP_META_FILENAME + "." + System.nanoTime()); try (FSDataOutputStream os = fileContext.create(file, EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE), Options.CreateOpts.CreateParent.createParent())) { JSONObject top = new JSONObject(); JSONObject attributes = new JSONObject(); for (Map.Entry<Attribute<?>, Object> entry : this.plan.getLogicalPlan().getAttributes().entrySet()) { attributes.put(entry.getKey().getSimpleName(), entry.getValue()); } JSONObject autoMetrics = new JSONObject(); for (Map.Entry<String, Map<String, Object>> entry : latestLogicalMetrics.entrySet()) { autoMetrics.put(entry.getKey(), new JSONArray(entry.getValue().keySet())); } top.put(APP_META_KEY_ATTRIBUTES, attributes); top.put(APP_META_KEY_METRICS, autoMetrics); os.write(top.toString().getBytes()); } catch (JSONException ex) { throw new RuntimeException(ex); } Path origPath = new Path(this.vars.appPath, APP_META_FILENAME); fileContext.rename(file, origPath, Options.Rename.OVERWRITE); }