@Override public ApplicationDto getApplication(String applicationId) throws ControlServiceException { return applicationService.findAppById(applicationId); }
@Override @Cacheable("apps") public ApplicationDto findAppById(String applicationId) { return applicationService.findAppById(applicationId); }
@Override public void onNotification(Notification notification) { ApplicationDto applicationDto = context.getApplicationService() .findAppById(notification.getAppId()); if (applicationDto != null) { LOG.debug("Sending message {} to EPS actor", notification); opsActor.tell(new ThriftNotificationMessage( applicationDto.getApplicationToken(), notification), ActorRef.noSender()); } else { LOG.warn("Can't find corresponding application for: {}", notification); } }
@Override public FileData getRecordStructureSchema(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService .findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } Schema recordWrapperSchema = null; try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(logCtlSchema.getBody()); } catch (IOException ex) { LOG.error("Unable to get Record Structure Schema", ex); throw new ControlServiceException(ex); } String libraryFileName = MessageFormatter .arrayFormat(SCHEMA_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); String schemaInJson = recordWrapperSchema.toString(true); byte[] schemaData = schemaInJson.getBytes(StandardCharsets.UTF_8); FileData schema = new FileData(); schema.setFileName(libraryFileName); schema.setFileData(schemaData); return schema; }
@Override public FileData generateRecordStructureLibrary(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); Schema recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(getFlatSchemaByCtlSchemaId(logCtlSchema.getId())); String fileName = MessageFormatter.arrayFormat(LOG_SCHEMA_LIBRARY_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); return SchemaLibraryGenerator.generateSchemaLibrary(recordWrapperSchema, fileName); } catch (Exception ex) { LOG.error("Unable to generate Record Structure Library", ex); throw new ControlServiceException(ex); } }
private void sendEndpointConfigurationRefreshMessage(EndpointSpecificConfigurationDto configuration) { byte[] endpointKeyHashBytes = configuration.getEndpointKeyHash(); EndpointProfileDto endpointProfile = endpointService.findEndpointProfileByKeyHash(endpointKeyHashBytes); if (!configuration.getConfigurationSchemaVersion().equals(endpointProfile.getConfigurationVersion())) { return; } checkNeighbors(); String endpointKeyHash = Base64Util.encode(configuration.getEndpointKeyHash()); ApplicationDto appDto = applicationService.findAppById(endpointProfile.getApplicationId()); OperationsNodeInfo server = resolve(endpointKeyHash); if (server != null) { ThriftEndpointConfigurationRefreshMessage msg = new ThriftEndpointConfigurationRefreshMessage(); msg.setAddress(new ThriftEntityAddress(appDto.getTenantId(), appDto.getApplicationToken(), ThriftClusterEntityType.ENDPOINT, ByteBuffer.wrap(endpointKeyHashBytes))); msg.setActorClassifier(ThriftActorClassifier.GLOBAL); if (LOG.isTraceEnabled()) { LOG.trace("Sending message {} to [{}]", msg, Neighbors.getServerId(server.getConnectionInfo())); } neighbors.sendMessage(server.getConnectionInfo(), OperationsServiceMsg.fromEndpointConfigurationRefresh(msg)); } else { LOG.warn("Can't find server for endpoint [{}]", endpointKeyHash); } }
@Override public FileData getRecordStructureData(RecordKey key) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(key.getApplicationId()); if (application == null) { throw new NotFoundException("Application not found!");
for (ApplicationEventFamilyMapDto mapping : mappingList) { String applicationId = mapping.getApplicationId(); ApplicationDto appDto = applicationService.findAppById(applicationId); RouteTableKey routeTableKey = new RouteTableKey( appDto.getApplicationToken(), new EventClassFamilyVersion(
@Test public void removeAppByIdTest() { ApplicationDto application = generateApplicationDto(); ApplicationDto foundApp = applicationService.findAppById(application.getId()); Assert.assertNotNull(foundApp); Assert.assertEquals(application.getId(), foundApp.getId()); applicationService.removeAppById(application.getId()); foundApp = applicationService.findAppById(application.getId()); Assert.assertNull(foundApp); }
ApplicationDto appDto = applicationService.findAppById(notification.getAppId()); LOG.debug("Processing cache notification {} for app {}", notification, appDto); if (appDto != null) {
@Test public void findAppByIdTest() { ApplicationDto application = generateApplicationDto(); ApplicationDto foundApp = applicationService.findAppById(application.getId()); Assert.assertNotNull(foundApp); Assert.assertEquals(application.getId(), foundApp.getId()); }
@Test public void saveMoreFiltersTest() { List<EndpointProfileSchemaDto> schemas = generateProfSchemaDto(null, null, 1); EndpointProfileSchemaDto schema = schemas.get(0); ApplicationDto app = applicationService.findAppById(schema.getApplicationId()); ServerProfileSchemaDto serverSchema = generateServerProfileSchema(app.getId(), app.getTenantId(), 1); generateFilterDto(schema.getId(), serverSchema.getId(), null, 10, true); List<ProfileFilterDto> filters = profileService.findProfileFiltersByAppIdAndVersionsCombination(schema.getApplicationId(), schema.getVersion(), serverSchema.getVersion()); Assert.assertFalse(filters.isEmpty()); Assert.assertEquals(filters.get(0).getStatus(), UpdateStatus.ACTIVE); Assert.assertEquals(schema.getId(), filters.get(0).getEndpointProfileSchemaId()); Assert.assertEquals(serverSchema.getId(), filters.get(0).getServerProfileSchemaId()); }
protected LogAppenderDto generateLogAppenderDto(String appId, String schemaId) { LogAppenderDto logAppender = null; ApplicationDto app = null; LogSchemaDto schema = null; if (isBlank(appId)) { app = generateApplicationDto(); appId = app.getId(); } else { app = applicationService.findAppById(appId); } if (isBlank(schemaId)) { schema = generateLogSchemaDto(appId, 1).get(0); } logAppender = new LogAppenderDto(); logAppender.setApplicationId(appId); logAppender.setName("Generated Appender"); int version = schema.getVersion(); logAppender.setMinLogSchemaVersion(version); logAppender.setMaxLogSchemaVersion(version); logAppender.setTenantId(app.getTenantId()); logAppender.setHeaderStructure(Arrays.asList(LogHeaderStructureDto.values())); return logAppendersService.saveLogAppender(logAppender); }
appId = app.getId(); } else { app = applicationService.findAppById(appId);
try { appToken = applicationService .findAppById(endpointProfileDto.getApplicationId()) .getApplicationToken(); byte[] config = deltaService
protected NotificationSchemaDto generateNotificationSchemaDto(String appId, NotificationTypeDto type) { NotificationSchemaDto schema = new NotificationSchemaDto(); ApplicationDto app = null; if (isBlank(appId)) { app = generateApplicationDto(); appId = app.getId(); } else { app = applicationService.findAppById(appId); } schema.setApplicationId(appId); schema.setName(NOTIFICATION_SCHEMA_NAME); schema.setType(type != null ? type : NotificationTypeDto.USER); CTLSchemaDto ctlSchema = null; try { ctlSchema = ctlService.saveCtlSchema(generateCTLSchemaDto(app.getTenantId())); } catch (DatabaseProcessingException e) { ctlSchema = ctlService.getOrCreateEmptySystemSchema(USER_NAME); } schema.setCtlSchemaId(ctlSchema.getId()); return notificationService.saveNotificationSchema(schema); }
schemaDto = profileService.findProfileSchemaById(schemaId); ApplicationDto app = applicationService.findAppById(schemaDto.getApplicationId());