@Test public void testPublishFolderPaths() throws IOException { AgentProviderService aps = createAgentProviderService(new Configuration()); StateAccessForProviders access = createNiceMock(StateAccessForProviders.class); AgentProviderService mockAps = Mockito.spy(aps); doReturn(access).when(mockAps).getAmState(); PublishedExportsSet pubExpSet = new PublishedExportsSet(); expect(access.getPublishedExportsSet()).andReturn(pubExpSet).anyTimes(); replay(access); Map<String, String> folders = new HashMap<String, String>(); folders.put("AGENT_LOG_ROOT", "aFolder"); folders.put("AGENT_WORK_ROOT", "folderB"); mockAps.publishFolderPaths(folders, "cid", "role", "fqdn"); PublishedExports exports = pubExpSet.get("container_log_dirs"); Assert.assertEquals(1, exports.entries.size()); List<ExportEntry> expEntries = exports.entries.get("role"); Assert.assertEquals(1, expEntries.size()); Assert.assertEquals("cid", expEntries.get(0).getContainerId()); Assert.assertEquals("component", expEntries.get(0).getLevel()); Assert.assertEquals("role", expEntries.get(0).getTag()); Assert.assertEquals("fqdn:aFolder", expEntries.get(0).getValue()); Assert.assertNull(expEntries.get(0).getValidUntil()); Assert.assertEquals(null, expEntries.get(0).getValidUntil()); exports = pubExpSet.get("container_work_dirs"); Assert.assertEquals(1, exports.entries.size()); expEntries = exports.entries.get("role"); Assert.assertEquals(1, expEntries.size()); Assert.assertEquals("cid", expEntries.get(0).getContainerId()); Assert.assertEquals("component", expEntries.get(0).getLevel()); Assert.assertEquals("role", expEntries.get(0).getTag()); Assert.assertEquals("fqdn:folderB", expEntries.get(0).getValue()); Assert.assertNull(expEntries.get(0).getValidUntil()); Assert.assertEquals(null, expEntries.get(0).getValidUntil()); }
protected void publishFolderPaths( Map<String, String> folders, String containerId, String componentName, String hostFqdn) { Date now = new Date(); for (Map.Entry<String, String> entry : folders.entrySet()) { ExportEntry exportEntry = new ExportEntry(); exportEntry.setValue(String.format(HOST_FOLDER_FORMAT, hostFqdn, entry.getValue())); exportEntry.setContainerId(containerId); exportEntry.setLevel(COMPONENT_TAG); exportEntry.setTag(componentName); exportEntry.setUpdatedTime(now.toString()); if (entry.getKey().equals("AGENT_LOG_ROOT")) { synchronized (logFolderExports) { getLogFolderExports().put(containerId, exportEntry); } } else { synchronized (workFolderExports) { getWorkFolderExports().put(containerId, exportEntry); } } log.info("Updating log and pwd folders for container {}", containerId); } PublishedExports exports = new PublishedExports(CONTAINER_LOGS_TAG); exports.setUpdated(now.getTime()); synchronized (logFolderExports) { updateExportsFromList(exports, getLogFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_LOGS_TAG, exports); exports = new PublishedExports(CONTAINER_PWDS_TAG); exports.setUpdated(now.getTime()); synchronized (workFolderExports) { updateExportsFromList(exports, getWorkFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_PWDS_TAG, exports); }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void publishFolderPaths( Map<String, String> folders, String containerId, String componentName, String hostFqdn) { Date now = new Date(); for (Map.Entry<String, String> entry : folders.entrySet()) { ExportEntry exportEntry = new ExportEntry(); exportEntry.setValue(String.format(HOST_FOLDER_FORMAT, hostFqdn, entry.getValue())); exportEntry.setContainerId(containerId); exportEntry.setLevel(COMPONENT_TAG); exportEntry.setTag(componentName); exportEntry.setUpdatedTime(now.toString()); if (entry.getKey().equals("AGENT_LOG_ROOT")) { synchronized (logFolderExports) { getLogFolderExports().put(containerId, exportEntry); } } else { synchronized (workFolderExports) { getWorkFolderExports().put(containerId, exportEntry); } } log.info("Updating log and pwd folders for container {}", containerId); } PublishedExports exports = new PublishedExports(CONTAINER_LOGS_TAG); exports.setUpdated(now.getTime()); synchronized (logFolderExports) { updateExportsFromList(exports, getLogFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_LOGS_TAG, exports); exports = new PublishedExports(CONTAINER_PWDS_TAG); exports.setUpdated(now.getTime()); synchronized (workFolderExports) { updateExportsFromList(exports, getWorkFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_PWDS_TAG, exports); } }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void publishFolderPaths( Map<String, String> folders, String containerId, String componentName, String hostFqdn) { Date now = new Date(); for (Map.Entry<String, String> entry : folders.entrySet()) { ExportEntry exportEntry = new ExportEntry(); exportEntry.setValue(String.format(HOST_FOLDER_FORMAT, hostFqdn, entry.getValue())); exportEntry.setContainerId(containerId); exportEntry.setLevel(COMPONENT_TAG); exportEntry.setTag(componentName); exportEntry.setUpdatedTime(now.toString()); if (entry.getKey().equals("AGENT_LOG_ROOT")) { synchronized (logFolderExports) { getLogFolderExports().put(containerId, exportEntry); } } else { synchronized (workFolderExports) { getWorkFolderExports().put(containerId, exportEntry); } } log.info("Updating log and pwd folders for container {}", containerId); } PublishedExports exports = new PublishedExports(CONTAINER_LOGS_TAG); exports.setUpdated(now.getTime()); synchronized (logFolderExports) { updateExportsFromList(exports, getLogFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_LOGS_TAG, exports); exports = new PublishedExports(CONTAINER_PWDS_TAG); exports.setUpdated(now.getTime()); synchronized (workFolderExports) { updateExportsFromList(exports, getWorkFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_PWDS_TAG, exports); } AgentProviderService(); }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void publishFolderPaths( Map<String, String> folders, String containerId, String componentName, String hostFqdn) { Date now = new Date(); for (Map.Entry<String, String> entry : folders.entrySet()) { ExportEntry exportEntry = new ExportEntry(); exportEntry.setValue(String.format(HOST_FOLDER_FORMAT, hostFqdn, entry.getValue())); exportEntry.setContainerId(containerId); exportEntry.setLevel(COMPONENT_TAG); exportEntry.setTag(componentName); exportEntry.setUpdatedTime(now.toString()); if (entry.getKey().equals("AGENT_LOG_ROOT")) { synchronized (logFolderExports) { getLogFolderExports().put(containerId, exportEntry); } } else { synchronized (workFolderExports) { getWorkFolderExports().put(containerId, exportEntry); } } log.info("Updating log and pwd folders for container {}", containerId); } PublishedExports exports = new PublishedExports(CONTAINER_LOGS_TAG); exports.setUpdated(now.getTime()); synchronized (logFolderExports) { updateExportsFromList(exports, getLogFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_LOGS_TAG, exports); exports = new PublishedExports(CONTAINER_PWDS_TAG); exports.setUpdated(now.getTime()); synchronized (workFolderExports) { updateExportsFromList(exports, getWorkFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_PWDS_TAG, exports); } AgentProviderService(); @Override String getHumanName(); @Override List<ProviderRole> getRoles(); @Override Configuration loadProviderConfigurationInformation(File confDir); @Override void validateInstanceDefinition(AggregateConf instanceDefinition); @Override void initializeApplicationConfiguration(
      AggregateConf instanceDefinition, SliderFileSystem fileSystem,
      String roleGroup); @Override void buildContainerLaunchContext(ContainerLauncher launcher,
                                          AggregateConf instanceDefinition,
                                          Container container,
                                          ProviderRole providerRole,
                                          SliderFileSystem fileSystem,
                                          Path generatedConfPath,
                                          MapOperations resourceComponent,
                                          MapOperations appComponent,
                                          Path containerTmpDirPath); @Override void rebuildContainerDetails(List<Container> liveContainers,
                                      String applicationId, Map<Integer, ProviderRole> providerRoleMap); @Override boolean isSupportedRole(String role); @Override RegistrationResponse handleRegistration(Register registration); @Override HeartBeatResponse handleHeartBeat(HeartBeat heartBeat); @Override Map<String, MonitorDetail> buildMonitorDetails(ClusterDescription clusterDesc); @Override void applyInitialRegistryDefinitions(URL amWebURI,
      URL agentOpsURI,
      URL agentStatusURI,
      ServiceRecord serviceRecord); @Override void notifyContainerCompleted(ContainerId containerId); void setInUpgradeMode(boolean inUpgradeMode); void addUpgradeContainers(Set<String> upgradeContainers); void setAppStopInitiated(boolean appStopInitiated); Map<String, String> buildProviderStatus(); }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void publishFolderPaths( Map<String, String> folders, String containerId, String componentName, String hostFqdn) { Date now = new Date(); for (Map.Entry<String, String> entry : folders.entrySet()) { ExportEntry exportEntry = new ExportEntry(); exportEntry.setValue(String.format(HOST_FOLDER_FORMAT, hostFqdn, entry.getValue())); exportEntry.setContainerId(containerId); exportEntry.setLevel(COMPONENT_TAG); exportEntry.setTag(componentName); exportEntry.setUpdatedTime(now.toString()); if (entry.getKey().equals("AGENT_LOG_ROOT")) { synchronized (logFolderExports) { getLogFolderExports().put(containerId, exportEntry); } } else { synchronized (workFolderExports) { getWorkFolderExports().put(containerId, exportEntry); } } log.info("Updating log and pwd folders for container {}", containerId); } PublishedExports exports = new PublishedExports(CONTAINER_LOGS_TAG); exports.setUpdated(now.getTime()); synchronized (logFolderExports) { updateExportsFromList(exports, getLogFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_LOGS_TAG, exports); exports = new PublishedExports(CONTAINER_PWDS_TAG); exports.setUpdated(now.getTime()); synchronized (workFolderExports) { updateExportsFromList(exports, getWorkFolderExports()); } getAmState().getPublishedExportsSet().put(CONTAINER_PWDS_TAG, exports); } AgentProviderService(); @Override String getHumanName(); @Override List<ProviderRole> getRoles(); @Override Configuration loadProviderConfigurationInformation(File confDir); @Override void validateInstanceDefinition(AggregateConf instanceDefinition); @Override void initializeApplicationConfiguration(
      AggregateConf instanceDefinition, SliderFileSystem fileSystem,
      String roleGroup); @Override void buildContainerLaunchContext(ContainerLauncher launcher,
                                          AggregateConf instanceDefinition,
                                          Container container,
                                          ProviderRole providerRole,
                                          SliderFileSystem fileSystem,
                                          Path generatedConfPath,
                                          MapOperations resourceComponent,
                                          MapOperations appComponent,
                                          Path containerTmpDirPath); @Override void rebuildContainerDetails(List<Container> liveContainers,
                                      String applicationId, Map<Integer, ProviderRole> providerRoleMap); @Override boolean isSupportedRole(String role); @Override RegistrationResponse handleRegistration(Register registration); @Override HeartBeatResponse handleHeartBeat(HeartBeat heartBeat); @Override Map<String, MonitorDetail> buildMonitorDetails(ClusterDescription clusterDesc); @Override void applyInitialRegistryDefinitions(URL amWebURI,
      URL agentOpsURI,
      URL agentStatusURI,
      ServiceRecord serviceRecord); @Override void notifyContainerCompleted(ContainerId containerId); void setInUpgradeMode(boolean inUpgradeMode); void addUpgradeContainers(Set<String> upgradeContainers); void setAppStopInitiated(boolean appStopInitiated); Map<String, String> buildProviderStatus();  }