public void addCustomFactory(Class<? extends FactoryService> factoryType) { addTable(td -> { td.useFactoryService(factoryType); }); }
public PostgresServiceDocumentDao(ServiceHost host, Service service, DataSource ds) { this.host = host; this.service = service; this.ds = ds; this.schemaManager = new PostgresSchemaManager(host); registerMBeans(); }
public void addFactory(String factoryLink, Class<? extends StatefulService> serviceType) { addTable(td -> { td.setFactoryLink(factoryLink); td.useStatefulService(serviceType); }); }
@Override protected void registerPostgresSchema(PostgresSchemaManager sm) { super.registerPostgresSchema(sm); sm.addFactory(TestService.class); sm.addFactory(TestPeriodicService.class); sm.addFactory(TestImmutableService.class); }
/** * Performs SQL initialization for the given document type, e.g. creating a dedicated table for * it, etc. * * Expected to be called once per document type upon host startup. */ public void initForDocument(String factoryLink, Class<? extends ServiceDocument> documentType, ServiceDocumentDescription sdd) { this.schemaManager.addFactory(factoryLink, documentType, sdd); TableDescription desc = this.schemaManager.getTableDescriptionForFactoryLink(factoryLink); if (desc != null) { ensureTableExists(desc); } }
@Override public void registerForServiceAvailability(Operation.CompletionHandler completion, String nodeSelectorPath, boolean checkReplica, String... servicePaths) { if (this.enablePostgres && checkReplica) { PostgresHostUtils.registerForReplicatedServiceAvailability(this, completion, isStarted() ? getSystemAuthorizationContext() : null, nodeSelectorPath, servicePaths); return; } super.registerForServiceAvailability(completion, nodeSelectorPath, checkReplica, servicePaths); }
void addFactory(String factoryLink, Class<? extends ServiceDocument> stateType, ServiceDocumentDescription sdd) { addTable(td -> { td.setFactoryLink(factoryLink); td.setStateType(stateType); td.setServiceDocumentDescription(sdd); }); }
public PostgresDocumentIndexService(ServiceHost host, DataSource ds) { super(ServiceDocument.class); toggleOption(ServiceOption.CORE, true); toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); // TODO: define how often to expire documents setMaintenanceIntervalMicros(TimeUnit.SECONDS.toMicros(1)); setHost(host); this.ds = ds; this.dao = new PostgresServiceDocumentDao(host, this, ds); }
@Override protected Service createDefaultDocumentIndexService() { if (!this.enablePostgres) { return super.createDefaultDocumentIndexService(); } setRemotePersistence(true); this.postgresDocumentIndexService = new PostgresDocumentIndexService(this, getDataSource()); return this.postgresDocumentIndexService; }
public PostgresLiquibaseSnapshot getSnapshot() { PostgresLiquibaseSnapshot snapshot = new PostgresLiquibaseSnapshot(); snapshot.addTableDescriptions(getTableDescriptions()); return snapshot; }
private void applyDocumentExpirationPolicy(long deadline) throws Exception { // TODO: need better solution to expire documents, this can be very slow to have // deletion in batches across tables int limit = expiredDocumentSearchThreshold; long now = Utils.getNowMicrosUtc(); for (TableDescription tableDescription : this.dao.getPostgresSchemaManager().getTableDescriptions()) { if (Utils.getSystemNowMicrosUtc() >= deadline || limit <= 0) { break; } int expired = applyDocumentExpirationPolicyForTable(tableDescription, now, deadline, limit); limit -= expired; } }
public void addFactory(StatefulService service) { addTable(td -> { td.useStatefulService(service); }); }
protected boolean validateLiquibaseSnapshot(PostgresSchemaManager schemaManager) throws Exception { return PostgresLiquibaseUtils.validateSnapshot(schemaManager.getSnapshot(), this.latestSnapshotResourcePath, true); }
PostgresSchemaManager getPostgresSchemaManager() { return this.postgresDocumentIndexService.getDao().getPostgresSchemaManager(); }
protected DataSource getDataSource() { if (this.ds == null) { this.ds = PostgresHostUtils.createDataSource(); } return this.ds; }
@Override public void setAuthorizationContext(AuthorizationContext context) { super.setAuthorizationContext(context); }
public static synchronized void closeDataSource() { if (ds != null) { PostgresHostUtils.closeDataSource(ds); ds = null; } }
public TableDescription setServiceDocumentDescription(ServiceDocumentDescription sdd) { this.sdd = sdd; buildColumns(); return this; }
public void addFactory(String factoryLink, StatefulService childService) { addTable(td -> { td.setFactoryLink(factoryLink); td.useStatefulService(childService); }); }
public void addFactory(Class<? extends StatefulService> serviceType) { addTable(td -> { td.useStatefulService(serviceType); }); }