Skip to content
Permalink
Browse files
Merge pull request #16 from aasaru/FINCN-180
FINCN-180 remove non-needed data source from configuration
  • Loading branch information
aasaru committed Oct 17, 2019
2 parents 9f10895 + d267864 commit 383e5e3f419fea7289b030693dbc59073062df8b
Showing 3 changed files with 19 additions and 23 deletions.
@@ -23,6 +23,8 @@
import java.util.List;
import java.util.Optional;

import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;
import org.apache.fineract.cn.anubis.api.v1.domain.AllowedOperation;
import org.apache.fineract.cn.api.context.AutoUserContext;
import org.apache.fineract.cn.api.util.ApiFactory;
@@ -42,8 +44,6 @@
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;

/**
@@ -52,7 +52,7 @@
@SuppressWarnings("WeakerAccess")
@Service
public class BeatPublisherService {
private final DiscoveryClient discoveryClient;
private final EurekaClient eurekaClient;
private final ApplicationPermissionRequestCreator applicationPermissionRequestCreator;
private final ApplicationAccessTokenService applicationAccessTokenService;
private final ApplicationName rhythmApplicationName;
@@ -62,14 +62,14 @@ public class BeatPublisherService {

@Autowired
public BeatPublisherService(
@SuppressWarnings("SpringJavaAutowiringInspection") final DiscoveryClient discoveryClient,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationPermissionRequestCreator applicationPermissionRequestCreator,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationAccessTokenService applicationAccessTokenService,
final ApplicationName rhythmApplicationName,
final ApiFactory apiFactory,
final RhythmProperties properties,
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
this.discoveryClient = discoveryClient;
@SuppressWarnings("SpringJavaAutowiringInspection") final EurekaClient eurekaClient,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationPermissionRequestCreator applicationPermissionRequestCreator,
@SuppressWarnings("SpringJavaAutowiringInspection") final ApplicationAccessTokenService applicationAccessTokenService,
final ApplicationName rhythmApplicationName,
final ApiFactory apiFactory,
final RhythmProperties properties,
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
this.eurekaClient = eurekaClient;
this.applicationPermissionRequestCreator = applicationPermissionRequestCreator;
this.applicationAccessTokenService = applicationAccessTokenService;
this.rhythmApplicationName = rhythmApplicationName;
@@ -138,12 +138,12 @@ public boolean publishBeat(
final BeatPublish beatPublish = new BeatPublish(beatIdentifier, DateConverter.toIsoString(timestamp));
logger.info("Attempting publish {} with timestamp {} under user {}.", beatPublish, timestamp, properties.getUser());

final List<ServiceInstance> applicationsByName = discoveryClient.getInstances(applicationIdentifier);
final List<InstanceInfo> applicationsByName = eurekaClient.getApplication(applicationIdentifier).getInstances();
if (applicationsByName.isEmpty())
return false;

final ServiceInstance beatListenerService = applicationsByName.get(0);
final BeatListener beatListener = apiFactory.create(BeatListener.class, beatListenerService.getUri().toString());
final InstanceInfo beatListenerService = applicationsByName.get(0);
final BeatListener beatListener = apiFactory.create(BeatListener.class, beatListenerService.getHomePageUrl());

try (final AutoTenantContext ignored = new AutoTenantContext(tenantIdentifier)) {
final String accessToken;
@@ -163,8 +163,8 @@ public boolean publishBeat(
}
}
catch (final Throwable e) {
logger.warn("Unable to publish beat '{}' to application '{}' for tenant '{}', " +
"because exception was thrown in publish.", beatIdentifier, applicationIdentifier, tenantIdentifier, e);
logger.warn("Unable to publish beat '{}' to application '{}' (uri: '{}') for tenant '{}' with user '{}'" +
"because exception was thrown in publish", beatIdentifier, applicationIdentifier,beatListenerService.getHomePageUrl(), tenantIdentifier, properties.getUser(), e);
return false;
}
}
@@ -23,17 +23,13 @@ spring:
enabled: false
config:
enabled: false
datasource:
driver-class-name: org.postgresql.Driver
platform: postgres
url: jdbc:postgresql://localhost:5432/seshat
username: postgres
password: postgres

eureka:
application:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
homePageUrl: "http://${eureka.hostname}:2022/rhythm/v1/"

server:
port: 2022
@@ -85,7 +85,7 @@ artifactory {
}
}
}
artifactoryPublish.dependsOn('clean','publishToMavenLocal')
artifactoryPublish.dependsOn('publishToMavenLocal')

license {
header rootProject.file('../HEADER')

0 comments on commit 383e5e3

Please sign in to comment.