/** * compute acceleration settings from the plan */ public static AccelerationSettings extractRefreshSettings(final RelNode normalizedPlan, ReflectionSettings reflectionSettings) { final boolean incremental = getIncremental(normalizedPlan, reflectionSettings); final String refreshField = !incremental ? null : findRefreshField(normalizedPlan, reflectionSettings); final RefreshMethod refreshMethod = incremental ? RefreshMethod.INCREMENTAL : RefreshMethod.FULL; return new AccelerationSettings() .setMethod(refreshMethod) .setRefreshField(refreshField); }
public AccelerationSettings toAccelerationSettings() { AccelerationSettings settings = new AccelerationSettings(); settings.setRefreshPeriod(getRefreshPeriodMs()); settings.setGracePeriod(getGracePeriodMs()); settings.setMethod(getMethod()); settings.setRefreshField(getRefreshField()); return settings; } }
.setMethod(descriptor.getMethod()) .setRefreshField(descriptor.getRefreshField()) .setNeverExpire(descriptor.getAccelerationNeverExpire()) settings.setRefreshPeriod(descriptor.getAccelerationRefreshPeriod()) .setGracePeriod(descriptor.getAccelerationGracePeriod()) .setMethod(descriptor.getMethod()) .setRefreshField(descriptor.getRefreshField()) .setNeverExpire(descriptor.getAccelerationNeverExpire())
settings.setRefreshPeriod(sourceConfig.getAccelerationRefreshPeriod()); settings.setGracePeriod(sourceConfig.getAccelerationGracePeriod()); settings.setMethod(RefreshMethod.FULL);
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); }
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) ); }
@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()); }