private List<LocalFile> getLocalizeFiles() throws IOException { try (Reader reader = Files.newBufferedReader(Paths.get(Constants.Files.LOCALIZE_FILES), StandardCharsets.UTF_8)) { return new GsonBuilder().registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .create().fromJson(reader, new TypeToken<List<LocalFile>>() { }.getType()); } }
private List<LocalFile> getLocalizeFiles() throws IOException { try (Reader reader = Files.newBufferedReader(Paths.get(Constants.Files.LOCALIZE_FILES), StandardCharsets.UTF_8)) { return new GsonBuilder().registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .create().fromJson(reader, new TypeToken<List<LocalFile>>() { }.getType()); } }
/** * Serializes the information for files that are localized to all YARN containers. */ private void createLocalizeFilesJson(Map<String, LocalFile> localFiles) throws IOException { LOG.debug("Create and copy {}", Constants.Files.LOCALIZE_FILES); Location location = createTempLocation(Constants.Files.LOCALIZE_FILES); // Serialize the list of LocalFiles, except the one we are generating here, as this file is used by AM only. // This file should never use LocationCache. try (Writer writer = new OutputStreamWriter(location.getOutputStream(), StandardCharsets.UTF_8)) { new GsonBuilder().registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .create().toJson(localFiles.values(), new TypeToken<List<LocalFile>>() { }.getType(), writer); } LOG.debug("Done {}", Constants.Files.LOCALIZE_FILES); localFiles.put(Constants.Files.LOCALIZE_FILES, createLocalFile(Constants.Files.LOCALIZE_FILES, location)); }
/** * Serializes the information for files that are localized to all YARN containers. */ private void createLocalizeFilesJson(Map<String, LocalFile> localFiles) throws IOException { LOG.debug("Create and copy {}", Constants.Files.LOCALIZE_FILES); Location location = createTempLocation(Constants.Files.LOCALIZE_FILES); // Serialize the list of LocalFiles, except the one we are generating here, as this file is used by AM only. // This file should never use LocationCache. try (Writer writer = new OutputStreamWriter(location.getOutputStream(), StandardCharsets.UTF_8)) { new GsonBuilder().registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .create().toJson(localFiles.values(), new TypeToken<List<LocalFile>>() { }.getType(), writer); } LOG.debug("Done {}", Constants.Files.LOCALIZE_FILES); localFiles.put(Constants.Files.LOCALIZE_FILES, createLocalFile(Constants.Files.LOCALIZE_FILES, location)); }
private TwillRuntimeSpecificationAdapter() { gson = new GsonBuilder() .serializeNulls() .registerTypeAdapter(TwillRuntimeSpecification.class, new TwillRuntimeSpecificationCodec()) .registerTypeAdapter(TwillSpecification.class, new TwillSpecificationCodec()) .registerTypeAdapter(TwillSpecification.Order.class, new TwillSpecificationOrderCoder()) .registerTypeAdapter(TwillSpecification.PlacementPolicy.class, new TwillSpecificationPlacementPolicyCoder()) .registerTypeAdapter(EventHandlerSpecification.class, new EventHandlerSpecificationCoder()) .registerTypeAdapter(RuntimeSpecification.class, new RuntimeSpecificationCodec()) .registerTypeAdapter(TwillRunnableSpecification.class, new TwillRunnableSpecificationCodec()) .registerTypeAdapter(ResourceSpecification.class, new ResourceSpecificationCodec()) .registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .registerTypeAdapterFactory(new TwillSpecificationTypeAdapterFactory()) .create(); }
private TwillRuntimeSpecificationAdapter() { gson = new GsonBuilder() .serializeNulls() .registerTypeAdapter(TwillRuntimeSpecification.class, new TwillRuntimeSpecificationCodec()) .registerTypeAdapter(TwillSpecification.class, new TwillSpecificationCodec()) .registerTypeAdapter(TwillSpecification.Order.class, new TwillSpecificationOrderCoder()) .registerTypeAdapter(TwillSpecification.PlacementPolicy.class, new TwillSpecificationPlacementPolicyCoder()) .registerTypeAdapter(EventHandlerSpecification.class, new EventHandlerSpecificationCoder()) .registerTypeAdapter(RuntimeSpecification.class, new RuntimeSpecificationCodec()) .registerTypeAdapter(TwillRunnableSpecification.class, new TwillRunnableSpecificationCodec()) .registerTypeAdapter(ResourceSpecification.class, new ResourceSpecificationCodec()) .registerTypeAdapter(LocalFile.class, new LocalFileCodec()) .registerTypeAdapterFactory(new TwillSpecificationTypeAdapterFactory()) .create(); }