@Test public void testLoadWorkLog() throws IOException { NetworkId network = new NetworkId("network"); SnapshotId snapshot = new SnapshotId("snapshot"); String workId = "workid"; Path logFile = getWorkLogPath(_containerDir.getParent(), network, snapshot, workId); final boolean mkdirs = logFile.getParent().toFile().mkdirs(); assertThat(mkdirs, equalTo(true)); CommonUtil.writeFile(logFile, "testoutput"); assertThat(_storage.loadWorkLog(network, snapshot, workId), equalTo("testoutput")); }
@Override @Nonnull public String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId) throws IOException { Path filePath = getWorkLogPath(network, snapshot, workId); if (!Files.exists(filePath)) { throw new FileNotFoundException( String.format("Could not find log file for work ID: %s", workId)); } return readFileToString(filePath, UTF_8); }
FileBasedStorage implements StorageProvider { @Override @Nonnull public String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId) throws IOException { Path filePath = getWorkLogPath(network, snapshot, workId); if (!Files.exists(filePath)) { throw new FileNotFoundException( String.format("Could not find log file for work ID: %s", workId)); } return readFileToString(filePath, UTF_8); } }
FileBasedStorage implements StorageProvider { @Override @Nonnull public String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId) throws IOException { Path filePath = getWorkLogPath(network, snapshot, workId); if (!Files.exists(filePath)) { throw new FileNotFoundException( String.format("Could not find log file for work ID: %s", workId)); } return readFileToString(filePath, UTF_8); } FileBasedStorage(
      Path baseDir, BatfishLogger logger, BiFunction<String, Integer, AtomicInteger> newBatch);  FileBasedStorage(Path baseDir, BatfishLogger logger); }
FileBasedStorage implements StorageProvider { @Override @Nonnull public String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId) throws IOException { Path filePath = getWorkLogPath(network, snapshot, workId); if (!Files.exists(filePath)) { throw new FileNotFoundException( String.format("Could not find log file for work ID: %s", workId)); } return readFileToString(filePath, UTF_8); } FileBasedStorage(
      Path baseDir, BatfishLogger logger, BiFunction<String, Integer, AtomicInteger> newBatch);  FileBasedStorage(Path baseDir, BatfishLogger logger); @Override @Nullable SortedMap<String, Configuration> loadConfigurations(
      NetworkId network, SnapshotId snapshot); @Override @Nullable ConvertConfigurationAnswerElement loadConvertConfigurationAnswerElement(
      NetworkId network, SnapshotId snapshot); @Override @Nullable SortedSet<NodeInterfacePair> loadInterfaceBlacklist(
      NetworkId network, SnapshotId snapshot); @Override @Nullable IspConfiguration loadIspConfiguration(NetworkId network, SnapshotId snapshot); @Override @Nullable SortedSet<String> loadNodeBlacklist(NetworkId network, SnapshotId snapshot); @Override @Nullable Layer1Topology loadLayer1Topology(NetworkId network, SnapshotId snapshot); @Override @Nonnull String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId); @Override @Nonnull String loadWorkJson(NetworkId network, SnapshotId snapshot, String workId); @Override @Nullable SnapshotRuntimeData loadRuntimeData(NetworkId network, SnapshotId snapshot); @Override void storeConfigurations(
      Map<String, Configuration> configurations,
      ConvertConfigurationAnswerElement convertAnswerElement,
      @Nullable Layer1Topology synthesizedLayer1Topology,
      NetworkId network,
      SnapshotId snapshot); @Override void storeAnswer(String answerStr, AnswerId answerId); @Override void storeAnswerMetadata(AnswerMetadata answerMetadata, AnswerId answerId); @Override @Nonnull String loadQuestion(
      NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override boolean checkQuestionExists(
      NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override @Nonnull String loadAnswer(AnswerId answerId); @Override @Nonnull AnswerMetadata loadAnswerMetadata(AnswerId answerId); @Override void storeQuestion(
      String questionStr, NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override boolean checkNetworkExists(NetworkId network); @Override boolean hasAnswerMetadata(AnswerId answerId); @Override String loadQuestionClassId(
      NetworkId networkId, QuestionId questionId, AnalysisId analysisId); @Override boolean hasAnalysisMetadata(NetworkId networkId, AnalysisId analysisId); @Override void storeAnalysisMetadata(
      AnalysisMetadata analysisMetadata, NetworkId networkId, AnalysisId analysisId); @Override String loadAnalysisMetadata(NetworkId networkId, AnalysisId analysisId); @Override void storeSnapshotMetadata(
      SnapshotMetadata snapshotMetadata, NetworkId networkId, SnapshotId snapshotId); @Override String loadSnapshotMetadata(NetworkId networkId, SnapshotId snapshotId); @Override void storeNodeRoles(NodeRolesData nodeRolesData, NodeRolesId nodeRolesId); @Override String loadNodeRoles(NodeRolesId nodeRolesId); @Override boolean hasNodeRoles(NodeRolesId nodeRolesId); @Override void initNetwork(NetworkId networkId); @Override void deleteAnswerMetadata(AnswerId answerId); @Override @Nonnull InputStream loadNetworkObject(NetworkId networkId, String key); @Override void storeNetworkObject(InputStream inputStream, NetworkId networkId, String key); @Override @Nonnull InputStream loadNetworkBlob(NetworkId networkId, String key); @Override void storeNetworkBlob(InputStream inputStream, NetworkId networkId, String key); @Override void deleteNetworkObject(NetworkId networkId, String key); static @Nonnull String toBase64(String key); static @Nonnull String fromBase64(String key); @Override @Nonnull InputStream loadSnapshotObject(
      NetworkId networkId, SnapshotId snapshotId, String key); @Override void storeSnapshotObject(
      InputStream inputStream, NetworkId networkId, SnapshotId snapshotId, String key); @Override void deleteSnapshotObject(NetworkId networkId, SnapshotId snapshotId, String key); @MustBeClosed @Override @Nonnull InputStream loadSnapshotInputObject(
      NetworkId networkId, SnapshotId snapshotId, String key); @Override boolean hasSnapshotInputObject(String key, NetworkSnapshot snapshot); @Override @Nonnull List<StoredObjectMetadata> getSnapshotInputObjectsMetadata(
      NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull List<StoredObjectMetadata> getSnapshotExtendedObjectsMetadata(
      NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull String loadPojoTopology(NetworkId networkId, SnapshotId snapshotId); static @Nonnull Path getWorkLogPath(
      Path baseDir, NetworkId network, SnapshotId snapshot, String workId); @Override @Nonnull String loadInitialTopology(NetworkId networkId, SnapshotId snapshotId); @Override void storeInitialTopology(Topology topology, NetworkId networkId, SnapshotId snapshotId); @Override void storePojoTopology(
      org.batfish.datamodel.pojo.Topology topology, NetworkId networkId, SnapshotId snapshotId); @Override void storeWorkLog(String logOutput, NetworkId network, SnapshotId snapshot, String workId); @Override void storeWorkJson(
      String jsonOutput, NetworkId network, SnapshotId snapshot, String workId); @Override CompletionMetadata loadCompletionMetadata(NetworkId networkId, SnapshotId snapshotId); @Override void storeCompletionMetadata(
      CompletionMetadata completionMetadata, NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull BgpTopology loadBgpTopology(NetworkSnapshot networkSnapshot); @Override @Nonnull EigrpTopology loadEigrpTopology(NetworkSnapshot networkSnapshot); @Nonnull @Override Optional<Layer1Topology> loadSynthesizedLayer1Topology(NetworkSnapshot snapshot); @Override @Nonnull Optional<Layer2Topology> loadLayer2Topology(NetworkSnapshot networkSnapshot); @Override @Nonnull Topology loadLayer3Topology(NetworkSnapshot networkSnapshot); @Override @Nonnull OspfTopology loadOspfTopology(NetworkSnapshot networkSnapshot); @Override @Nonnull VxlanTopology loadVxlanTopology(NetworkSnapshot networkSnapshot); @Override void storeBgpTopology(BgpTopology bgpTopology, NetworkSnapshot networkSnapshot); @Override void storeEigrpTopology(EigrpTopology eigrpTopology, NetworkSnapshot networkSnapshot); @Override void storeLayer2Topology(
      Optional<Layer2Topology> layer2Topology, NetworkSnapshot networkSnapshot); @Override void storeLayer3Topology(Topology layer3Topology, NetworkSnapshot networkSnapshot); @Override void storeOspfTopology(OspfTopology ospfTopology, NetworkSnapshot networkSnapshot); @Override void storeVxlanTopology(VxlanTopology vxlanTopology, NetworkSnapshot networkSnapshot); @Override @Nonnull Optional<String> readId(Class<? extends Id> idType, String name, Id... ancestors); @Override void writeId(Id id, String name, Id... ancestors); @Override boolean deleteNameIdMapping(Class<? extends Id> type, String name, Id... ancestors); @Override boolean hasId(Class<? extends Id> type, String name, Id... ancestors); @Override @Nonnull Set<String> listResolvableNames(Class<? extends Id> type, Id... ancestors); @Nonnull @Override Optional<ReferenceLibrary> loadReferenceLibrary(NetworkId network); @Override void storeReferenceLibrary(ReferenceLibrary referenceLibrary, NetworkId network); @Override void storeUploadSnapshotZip(InputStream inputStream, String key, NetworkId network); @Override void storeForkSnapshotRequest(String forkSnapshotRequest, String key, NetworkId network); @MustBeClosed @Nonnull @Override InputStream loadUploadSnapshotZip(String key, NetworkId network); @Override void storeSnapshotInputObject(
      InputStream inputStream, String key, NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listSnapshotInputObjectKeys(NetworkSnapshot snapshot); @Nonnull @Override DataPlane loadDataPlane(NetworkSnapshot snapshot); @Override void storeDataPlane(DataPlane dataPlane, NetworkSnapshot snapshot); @Override boolean hasDataPlane(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputEnvironmentBgpTableKeys(NetworkSnapshot snapshot); @Nonnull @Override ParseEnvironmentBgpTablesAnswerElement loadParseEnvironmentBgpTablesAnswerElement(
      NetworkSnapshot snapshot); @Override void storeParseEnvironmentBgpTablesAnswerElement(
      ParseEnvironmentBgpTablesAnswerElement parseEnvironmentBgpTablesAnswerElement,
      NetworkSnapshot snapshot); @Override boolean hasParseEnvironmentBgpTablesAnswerElement(NetworkSnapshot snapshot); @Override void deleteParseEnvironmentBgpTablesAnswerElement(NetworkSnapshot snapshot); @Nonnull @Override Map<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables(NetworkSnapshot snapshot); @Override void storeEnvironmentBgpTables(
      Map<String, BgpAdvertisementsByVrf> environmentBgpTables, NetworkSnapshot snapshot); @Override void deleteEnvironmentBgpTables(NetworkSnapshot snapshot); @Nonnull @Override Optional<String> loadExternalBgpAnnouncementsFile(NetworkSnapshot snapshot); @Nonnull @Override ParseVendorConfigurationAnswerElement loadParseVendorConfigurationAnswerElement(
      NetworkSnapshot snapshot); @Override void storeParseVendorConfigurationAnswerElement(
      ParseVendorConfigurationAnswerElement parseVendorConfigurationAnswerElement,
      NetworkSnapshot snapshot); @Override boolean hasParseVendorConfigurationAnswerElement(NetworkSnapshot snapshot); @Override void deleteParseVendorConfigurationAnswerElement(NetworkSnapshot snapshot); @Nonnull @Override Map<String, VendorConfiguration> loadVendorConfigurations(NetworkSnapshot snapshot); @Override void storeVendorConfigurations(
      Map<String, VendorConfiguration> vendorConfigurations, NetworkSnapshot snapshot); @Override void deleteVendorConfigurations(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputHostConfigurationsKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputNetworkConfigurationsKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputAwsMultiAccountKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputAwsSingleAccountKeys(NetworkSnapshot snapshot); @Override void runGarbageCollection(Instant expungeBeforeDate); }
FileBasedStorage implements StorageProvider { @Override @Nonnull public String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId) throws IOException { Path filePath = getWorkLogPath(network, snapshot, workId); if (!Files.exists(filePath)) { throw new FileNotFoundException( String.format("Could not find log file for work ID: %s", workId)); } return readFileToString(filePath, UTF_8); } FileBasedStorage(
      Path baseDir, BatfishLogger logger, BiFunction<String, Integer, AtomicInteger> newBatch);  FileBasedStorage(Path baseDir, BatfishLogger logger); @Override @Nullable SortedMap<String, Configuration> loadConfigurations(
      NetworkId network, SnapshotId snapshot); @Override @Nullable ConvertConfigurationAnswerElement loadConvertConfigurationAnswerElement(
      NetworkId network, SnapshotId snapshot); @Override @Nullable SortedSet<NodeInterfacePair> loadInterfaceBlacklist(
      NetworkId network, SnapshotId snapshot); @Override @Nullable IspConfiguration loadIspConfiguration(NetworkId network, SnapshotId snapshot); @Override @Nullable SortedSet<String> loadNodeBlacklist(NetworkId network, SnapshotId snapshot); @Override @Nullable Layer1Topology loadLayer1Topology(NetworkId network, SnapshotId snapshot); @Override @Nonnull String loadWorkLog(NetworkId network, SnapshotId snapshot, String workId); @Override @Nonnull String loadWorkJson(NetworkId network, SnapshotId snapshot, String workId); @Override @Nullable SnapshotRuntimeData loadRuntimeData(NetworkId network, SnapshotId snapshot); @Override void storeConfigurations(
      Map<String, Configuration> configurations,
      ConvertConfigurationAnswerElement convertAnswerElement,
      @Nullable Layer1Topology synthesizedLayer1Topology,
      NetworkId network,
      SnapshotId snapshot); @Override void storeAnswer(String answerStr, AnswerId answerId); @Override void storeAnswerMetadata(AnswerMetadata answerMetadata, AnswerId answerId); @Override @Nonnull String loadQuestion(
      NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override boolean checkQuestionExists(
      NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override @Nonnull String loadAnswer(AnswerId answerId); @Override @Nonnull AnswerMetadata loadAnswerMetadata(AnswerId answerId); @Override void storeQuestion(
      String questionStr, NetworkId network, QuestionId question, @Nullable AnalysisId analysis); @Override boolean checkNetworkExists(NetworkId network); @Override boolean hasAnswerMetadata(AnswerId answerId); @Override String loadQuestionClassId(
      NetworkId networkId, QuestionId questionId, AnalysisId analysisId); @Override boolean hasAnalysisMetadata(NetworkId networkId, AnalysisId analysisId); @Override void storeAnalysisMetadata(
      AnalysisMetadata analysisMetadata, NetworkId networkId, AnalysisId analysisId); @Override String loadAnalysisMetadata(NetworkId networkId, AnalysisId analysisId); @Override void storeSnapshotMetadata(
      SnapshotMetadata snapshotMetadata, NetworkId networkId, SnapshotId snapshotId); @Override String loadSnapshotMetadata(NetworkId networkId, SnapshotId snapshotId); @Override void storeNodeRoles(NodeRolesData nodeRolesData, NodeRolesId nodeRolesId); @Override String loadNodeRoles(NodeRolesId nodeRolesId); @Override boolean hasNodeRoles(NodeRolesId nodeRolesId); @Override void initNetwork(NetworkId networkId); @Override void deleteAnswerMetadata(AnswerId answerId); @Override @Nonnull InputStream loadNetworkObject(NetworkId networkId, String key); @Override void storeNetworkObject(InputStream inputStream, NetworkId networkId, String key); @Override @Nonnull InputStream loadNetworkBlob(NetworkId networkId, String key); @Override void storeNetworkBlob(InputStream inputStream, NetworkId networkId, String key); @Override void deleteNetworkObject(NetworkId networkId, String key); static @Nonnull String toBase64(String key); static @Nonnull String fromBase64(String key); @Override @Nonnull InputStream loadSnapshotObject(
      NetworkId networkId, SnapshotId snapshotId, String key); @Override void storeSnapshotObject(
      InputStream inputStream, NetworkId networkId, SnapshotId snapshotId, String key); @Override void deleteSnapshotObject(NetworkId networkId, SnapshotId snapshotId, String key); @MustBeClosed @Override @Nonnull InputStream loadSnapshotInputObject(
      NetworkId networkId, SnapshotId snapshotId, String key); @Override boolean hasSnapshotInputObject(String key, NetworkSnapshot snapshot); @Override @Nonnull List<StoredObjectMetadata> getSnapshotInputObjectsMetadata(
      NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull List<StoredObjectMetadata> getSnapshotExtendedObjectsMetadata(
      NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull String loadPojoTopology(NetworkId networkId, SnapshotId snapshotId); static @Nonnull Path getWorkLogPath(
      Path baseDir, NetworkId network, SnapshotId snapshot, String workId); @Override @Nonnull String loadInitialTopology(NetworkId networkId, SnapshotId snapshotId); @Override void storeInitialTopology(Topology topology, NetworkId networkId, SnapshotId snapshotId); @Override void storePojoTopology(
      org.batfish.datamodel.pojo.Topology topology, NetworkId networkId, SnapshotId snapshotId); @Override void storeWorkLog(String logOutput, NetworkId network, SnapshotId snapshot, String workId); @Override void storeWorkJson(
      String jsonOutput, NetworkId network, SnapshotId snapshot, String workId); @Override CompletionMetadata loadCompletionMetadata(NetworkId networkId, SnapshotId snapshotId); @Override void storeCompletionMetadata(
      CompletionMetadata completionMetadata, NetworkId networkId, SnapshotId snapshotId); @Override @Nonnull BgpTopology loadBgpTopology(NetworkSnapshot networkSnapshot); @Override @Nonnull EigrpTopology loadEigrpTopology(NetworkSnapshot networkSnapshot); @Nonnull @Override Optional<Layer1Topology> loadSynthesizedLayer1Topology(NetworkSnapshot snapshot); @Override @Nonnull Optional<Layer2Topology> loadLayer2Topology(NetworkSnapshot networkSnapshot); @Override @Nonnull Topology loadLayer3Topology(NetworkSnapshot networkSnapshot); @Override @Nonnull OspfTopology loadOspfTopology(NetworkSnapshot networkSnapshot); @Override @Nonnull VxlanTopology loadVxlanTopology(NetworkSnapshot networkSnapshot); @Override void storeBgpTopology(BgpTopology bgpTopology, NetworkSnapshot networkSnapshot); @Override void storeEigrpTopology(EigrpTopology eigrpTopology, NetworkSnapshot networkSnapshot); @Override void storeLayer2Topology(
      Optional<Layer2Topology> layer2Topology, NetworkSnapshot networkSnapshot); @Override void storeLayer3Topology(Topology layer3Topology, NetworkSnapshot networkSnapshot); @Override void storeOspfTopology(OspfTopology ospfTopology, NetworkSnapshot networkSnapshot); @Override void storeVxlanTopology(VxlanTopology vxlanTopology, NetworkSnapshot networkSnapshot); @Override @Nonnull Optional<String> readId(Class<? extends Id> idType, String name, Id... ancestors); @Override void writeId(Id id, String name, Id... ancestors); @Override boolean deleteNameIdMapping(Class<? extends Id> type, String name, Id... ancestors); @Override boolean hasId(Class<? extends Id> type, String name, Id... ancestors); @Override @Nonnull Set<String> listResolvableNames(Class<? extends Id> type, Id... ancestors); @Nonnull @Override Optional<ReferenceLibrary> loadReferenceLibrary(NetworkId network); @Override void storeReferenceLibrary(ReferenceLibrary referenceLibrary, NetworkId network); @Override void storeUploadSnapshotZip(InputStream inputStream, String key, NetworkId network); @Override void storeForkSnapshotRequest(String forkSnapshotRequest, String key, NetworkId network); @MustBeClosed @Nonnull @Override InputStream loadUploadSnapshotZip(String key, NetworkId network); @Override void storeSnapshotInputObject(
      InputStream inputStream, String key, NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listSnapshotInputObjectKeys(NetworkSnapshot snapshot); @Nonnull @Override DataPlane loadDataPlane(NetworkSnapshot snapshot); @Override void storeDataPlane(DataPlane dataPlane, NetworkSnapshot snapshot); @Override boolean hasDataPlane(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputEnvironmentBgpTableKeys(NetworkSnapshot snapshot); @Nonnull @Override ParseEnvironmentBgpTablesAnswerElement loadParseEnvironmentBgpTablesAnswerElement(
      NetworkSnapshot snapshot); @Override void storeParseEnvironmentBgpTablesAnswerElement(
      ParseEnvironmentBgpTablesAnswerElement parseEnvironmentBgpTablesAnswerElement,
      NetworkSnapshot snapshot); @Override boolean hasParseEnvironmentBgpTablesAnswerElement(NetworkSnapshot snapshot); @Override void deleteParseEnvironmentBgpTablesAnswerElement(NetworkSnapshot snapshot); @Nonnull @Override Map<String, BgpAdvertisementsByVrf> loadEnvironmentBgpTables(NetworkSnapshot snapshot); @Override void storeEnvironmentBgpTables(
      Map<String, BgpAdvertisementsByVrf> environmentBgpTables, NetworkSnapshot snapshot); @Override void deleteEnvironmentBgpTables(NetworkSnapshot snapshot); @Nonnull @Override Optional<String> loadExternalBgpAnnouncementsFile(NetworkSnapshot snapshot); @Nonnull @Override ParseVendorConfigurationAnswerElement loadParseVendorConfigurationAnswerElement(
      NetworkSnapshot snapshot); @Override void storeParseVendorConfigurationAnswerElement(
      ParseVendorConfigurationAnswerElement parseVendorConfigurationAnswerElement,
      NetworkSnapshot snapshot); @Override boolean hasParseVendorConfigurationAnswerElement(NetworkSnapshot snapshot); @Override void deleteParseVendorConfigurationAnswerElement(NetworkSnapshot snapshot); @Nonnull @Override Map<String, VendorConfiguration> loadVendorConfigurations(NetworkSnapshot snapshot); @Override void storeVendorConfigurations(
      Map<String, VendorConfiguration> vendorConfigurations, NetworkSnapshot snapshot); @Override void deleteVendorConfigurations(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputHostConfigurationsKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputNetworkConfigurationsKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputAwsMultiAccountKeys(NetworkSnapshot snapshot); @MustBeClosed @Nonnull @Override Stream<String> listInputAwsSingleAccountKeys(NetworkSnapshot snapshot); @Override void runGarbageCollection(Instant expungeBeforeDate);  }