accelerationSettings.setGracePeriod(NamespaceService.INFINITE_REFRESH_PERIOD); } else { accelerationSettings.setGracePeriod(pdsAccelerationTTLInMillis * 3L);
public AccelerationSettings toAccelerationSettings() { AccelerationSettings settings = new AccelerationSettings(); settings.setRefreshPeriod(getRefreshPeriodMs()); settings.setGracePeriod(getGracePeriodMs()); settings.setMethod(getMethod()); settings.setRefreshField(getRefreshField()); return settings; } }
.setGracePeriod(descriptor.getAccelerationGracePeriod()) .setMethod(descriptor.getMethod()) .setRefreshField(descriptor.getRefreshField()) if (settingsUpdated) { settings.setRefreshPeriod(descriptor.getAccelerationRefreshPeriod()) .setGracePeriod(descriptor.getAccelerationGracePeriod()) .setMethod(descriptor.getMethod()) .setRefreshField(descriptor.getRefreshField())
public void setReflectionSettings(NamespaceKey key, AccelerationSettings settings) { // if some settings already exist just override them, otherwise remove the version as the passed settings may be // coming from the parent source AccelerationSettings previous = store.get(key); settings.setTag(previous != null ? previous.getTag() : null); // version is deprecated but may exist after an upgrade so we need to ensure that it is nulled out when we null out // the tag or else the inline upgrade code for OCC will get confused settings.setVersion(previous != null ? previous.getVersion() : null); if (settings.getRefreshPeriod() == null) { settings.setRefreshPeriod(DEFAULT_REFRESH_PERIOD); } if (settings.getGracePeriod() == null) { settings.setGracePeriod(DEFAULT_GRACE_PERIOD); } store.save(key, settings); }
return new AccelerationSettings() .setMethod(RefreshMethod.FULL) .setGracePeriod(DEFAULT_REFRESH_PERIOD) .setRefreshPeriod(DEFAULT_GRACE_PERIOD);
@Test public void testDeleteSource() throws Exception { SourceConfig sourceConfig = new SourceConfig(); sourceConfig.setName("mySource"); sourceConfig.setId(new EntityId("source-id")); sourceConfig.setTag("1"); sourceConfig.setType("NAS"); AccelerationSettings settings = new AccelerationSettings(); settings.setGracePeriod(1L); settings.setRefreshPeriod(1L); Source source = new Source(sourceConfig, settings, mock(ConnectionReader.class)); NameSpaceContainer namespaceContainer = new NameSpaceContainer(); namespaceContainer.setType(NameSpaceContainer.Type.SOURCE); namespaceContainer.setSource(sourceConfig); when(namespaceService.getEntityById(source.getId())).thenReturn(namespaceContainer); catalogServiceHelper.deleteCatalogItem(source.getId(), "1"); verify(sourceService, times(1)).deleteSource(sourceConfig); }
settings.setGracePeriod(sourceConfig.getAccelerationGracePeriod()); settings.setMethod(RefreshMethod.FULL);
protected void setDatasetAccelerationSettings(NamespaceKey key, long refreshPeriod, long gracePeriod, boolean incremental, String refreshField, boolean neverExpire, boolean neverRefresh) { // update dataset refresh/grace period getReflectionService().getReflectionSettings().setReflectionSettings(key, new AccelerationSettings() .setMethod(incremental ? RefreshMethod.INCREMENTAL : RefreshMethod.FULL) .setRefreshPeriod(refreshPeriod) .setGracePeriod(gracePeriod) .setRefreshField(refreshField) .setNeverExpire(neverExpire) .setNeverRefresh(neverRefresh) ); }
private SourceConfig registerSourceWithRuntime(SourceConfig sourceConfig, Catalog catalog, NamespaceAttribute... attributes) throws ExecutionSetupException, NamespaceException { if(sourceConfig.getTag() == null) { catalog.createSource(sourceConfig, attributes); } else { catalog.updateSource(sourceConfig, attributes); } final NamespaceKey key = new NamespaceKey(sourceConfig.getName()); reflectionServiceHelper.getReflectionSettings().setReflectionSettings(key, new AccelerationSettings() .setMethod(RefreshMethod.FULL) .setRefreshPeriod(sourceConfig.getAccelerationRefreshPeriod()) .setGracePeriod(sourceConfig.getAccelerationGracePeriod()) .setNeverExpire(sourceConfig.getAccelerationNeverExpire()) .setNeverRefresh(sourceConfig.getAccelerationNeverRefresh())); return namespaceService.getSource(key); }
@Test public void testUpdateSourceErrors() throws Exception { SourceConfig sourceConfig = new SourceConfig(); sourceConfig.setName("Foopy5"); NASConf nasConfig = new NASConf(); sourceConfig.setType(nasConfig.getType()); nasConfig.path = "/"; sourceConfig.setConfig(nasConfig.toBytesString()); SourceConfig createdSourceConfig = newSourceService().registerSourceWithRuntime(sourceConfig); final AccelerationSettings settings = new AccelerationSettings() .setMethod(RefreshMethod.FULL) .setRefreshPeriod(TimeUnit.HOURS.toMillis(2)) .setGracePeriod(TimeUnit.HOURS.toMillis(6)); SourceResource.SourceDeprecated updatedSource = new SourceResource.SourceDeprecated(createdSourceConfig, settings, reader); // test updating non-existent source expectStatus(Response.Status.NOT_FOUND, getBuilder(getPublicAPI(3).path(SOURCES_PATH).path("badid")).buildPut(Entity.entity(updatedSource, JSON))); // test wrong tag updatedSource.setTag("badtag"); expectStatus(Response.Status.CONFLICT, getBuilder(getPublicAPI(3).path(SOURCES_PATH).path(createdSourceConfig.getId().getId())).buildPut(Entity.entity(updatedSource, JSON))); newNamespaceService().deleteSource(new SourcePath(updatedSource.getName()).toNamespaceKey(), createdSourceConfig.getTag()); }
@Test public void testUpdateSource() throws Exception { SourceConfig sourceConfig = new SourceConfig(); sourceConfig.setName("Foopy2"); NASConf nasConfig = new NASConf(); sourceConfig.setType(nasConfig.getType()); nasConfig.path = "/"; sourceConfig.setConfig(nasConfig.toBytesString()); SourceConfig createdSourceConfig = newSourceService().registerSourceWithRuntime(sourceConfig); final AccelerationSettings settings = new AccelerationSettings() .setMethod(RefreshMethod.FULL) .setRefreshPeriod(TimeUnit.HOURS.toMillis(2)) .setGracePeriod(TimeUnit.HOURS.toMillis(6)); SourceResource.SourceDeprecated updatedSource = new SourceResource.SourceDeprecated(createdSourceConfig, settings, reader); updatedSource.setDescription("Desc"); SourceResource.SourceDeprecated source = expectSuccess(getBuilder(getPublicAPI(3).path(SOURCES_PATH).path(createdSourceConfig.getId().getId())).buildPut(Entity.entity(updatedSource, JSON)), SourceResource.SourceDeprecated.class); assertEquals(source.getDescription(), "Desc"); assertEquals(source.getTag(), "1"); assertNotNull(source.getState()); newNamespaceService().deleteSource(new SourcePath(source.getName()).toNamespaceKey(), source.getTag()); }
.setMethod(RefreshMethod.FULL) .setRefreshPeriod(TimeUnit.HOURS.toMillis(2)) .setGracePeriod(TimeUnit.HOURS.toMillis(6));
@Test public void testUpdateSourceBoundaryValues() throws Exception { SourceConfig sourceConfig = new SourceConfig(); sourceConfig.setName("Foopy2"); NASConf nasConfig = new NASConf(); sourceConfig.setType(nasConfig.getType()); nasConfig.path = "/"; sourceConfig.setConfig(nasConfig.toBytesString()); SourceConfig createdSourceConfig = newSourceService().registerSourceWithRuntime(sourceConfig); final AccelerationSettings settings = new AccelerationSettings() .setMethod(RefreshMethod.FULL) .setRefreshPeriod(TimeUnit.HOURS.toMillis(2)) .setGracePeriod(TimeUnit.HOURS.toMillis(6)); SourceResource.SourceDeprecated updatedSource = new SourceResource.SourceDeprecated(createdSourceConfig, settings, reader); updatedSource.getMetadataPolicy().setDatasetRefreshAfterMs(MetadataPolicy.ONE_MINUTE_IN_MS); updatedSource.getMetadataPolicy().setAuthTTLMs(MetadataPolicy.ONE_MINUTE_IN_MS); updatedSource.getMetadataPolicy().setNamesRefreshMs(MetadataPolicy.ONE_MINUTE_IN_MS); SourceResource.SourceDeprecated source = expectSuccess(getBuilder(getPublicAPI(3).path(SOURCES_PATH).path(createdSourceConfig.getId().getId())).buildPut(Entity.entity(updatedSource, JSON)), SourceResource.SourceDeprecated.class); assertEquals(source.getMetadataPolicy().getAuthTTLMs(), updatedSource.getMetadataPolicy().getAuthTTLMs()); assertEquals(source.getMetadataPolicy().getDatasetRefreshAfterMs(), updatedSource.getMetadataPolicy().getDatasetRefreshAfterMs()); assertEquals(source.getMetadataPolicy().getNamesRefreshMs(), updatedSource.getMetadataPolicy().getNamesRefreshMs()); newNamespaceService().deleteSource(new SourcePath(createdSourceConfig.getName()).toNamespaceKey(), source.getTag()); }