Skip to content

Commit

Permalink
PAYARA-3111 requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cousjava committed Apr 23, 2019
1 parent 6c01ff1 commit 434e05c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public static void updateNotifiers(HandlerContext handlerCtx) {
for (String notifier : notifiers){
String name = notifier.split("-")[1];
String restEndpoint;
HashMap<String, Object> attrs = new HashMap<>();
Map<String, Object> attributes = new HashMap<>();
if (endpoint.contains("request-tracing-service-configuration")){
restEndpoint = endpoint + "/requesttracing-" + name + "-notifier-configure";
forRequestTracing = true;
Expand All @@ -591,7 +591,7 @@ public static void updateNotifiers(HandlerContext handlerCtx) {
forMonitoring = true;
} else if (endpoint.contains("admin-audit-configuration")) {
restEndpoint = endpoint + "/set-admin-audit-service-notifier-configuration";
attrs.put("notifier", name);
attributes.put("notifier", name);
forAdminAudit = true;
} else {
//Unknown service being configured
Expand All @@ -600,18 +600,18 @@ public static void updateNotifiers(HandlerContext handlerCtx) {


if (enabledNotifiers.contains(notifier)){
attrs.put("enabled", "true");
attributes.put("enabled", "true");
} else {
attrs.put("enabled", "false");
attributes.put("enabled", "false");
}
if (!forAdminAudit) {
//PAYARA-1616 go silent, bootstrap will take place after iteration.
attrs.put("dynamic", "false");
attributes.put("dynamic", "false");
} else {
attrs.put("dynamic", "true");
attributes.put("dynamic", "true");
}
attrs.put("target", target);
RestUtil.restRequest(restEndpoint, attrs, "post", handlerCtx, quiet, throwException);
attributes.put("target", target);
RestUtil.restRequest(restEndpoint, attributes, "post", handlerCtx, quiet, throwException);
}
// PAYARA-1616
// manually bootstrap healthCheck and requestTracing services for once so that it doesn't get bootstrapped each time for enabled notifier.
Expand Down Expand Up @@ -824,4 +824,4 @@ public static void createDeploymentGroupInstances(HandlerContext handlerCtx) {
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ public static RestActionReporter runCommand(String commandName,
ParameterMap parameters,
Subject subject,
boolean managedJob) {
AsadminRecorderService asadminRecorderService = Globals.
getDefaultHabitat().getService(AsadminRecorderService.class);
AsadminRecorderService asadminRecorderService = Globals.get(AsadminRecorderService.class);
if (asadminRecorderService != null && asadminRecorderService.isEnabled()) {
asadminRecorderService.recordAsadminCommand(commandName,
parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,21 @@
*/
public class RunCommandTest {

private ServiceLocator habitat;
private ServiceLocator serviceLocator;

private List<NotificationEvent> events;

@Before
public void setUp() {
habitat = ServiceLocatorFactory.getInstance().create("testServiceLocator");
ServiceLocatorUtilities.addOneConstant(habitat, new TestNotificationService());
ServiceLocatorUtilities.addOneConstant(habitat, this);
ServiceLocatorUtilities.addClasses(habitat, AdminAuditService.class, GetAdminAuditServiceConfiguration.class, TestConfiguration.class,
serviceLocator = ServiceLocatorFactory.getInstance().create("testServiceLocator");
ServiceLocatorUtilities.addOneConstant(serviceLocator, new TestNotificationService());
ServiceLocatorUtilities.addOneConstant(serviceLocator, this);
ServiceLocatorUtilities.addClasses(serviceLocator, AdminAuditService.class, GetAdminAuditServiceConfiguration.class, TestConfiguration.class,
Target.class, NotificationEventFactoryStore.class, NotifierExecutionOptionsFactoryStore.class, TestCommandRunner.class);

Globals.setDefaultHabitat(habitat);
Globals.setDefaultHabitat(serviceLocator);

DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class);
DynamicConfiguration config = dcs.createDynamicConfiguration();

config.addActiveDescriptor(RunLevelControllerImpl.class);
Expand All @@ -134,8 +134,8 @@ public void setUp() {

config.commit();

habitat.getService(RunLevelController.class).proceedTo(StartupRunLevel.VAL);
habitat.getService(NotificationEventFactoryStore.class).register(NotifierType.LOG, new fish.payara.nucleus.notification.log.LogNotificationEventFactory() {
serviceLocator.getService(RunLevelController.class).proceedTo(StartupRunLevel.VAL);
serviceLocator.getService(NotificationEventFactoryStore.class).register(NotifierType.LOG, new fish.payara.nucleus.notification.log.LogNotificationEventFactory() {
@Override
public LogNotificationEvent buildNotificationEvent(Level level, String subject, String message, Object[] parameters) {
LogNotificationEvent event = new LogNotificationEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class GetAdminAuditServiceConfiguration implements AdminCommand {
private final static String[] NOTIFIER_HEADERS= {"Name", "Notifier Enabled"};

@Inject
ServiceLocator habitat;
ServiceLocator serviceLocator;

@Param(name = "target", optional = true, defaultValue = SystemPropertyConstants.DAS_SERVER_NAME)
private String target;
Expand Down Expand Up @@ -128,7 +128,7 @@ public void execute(AdminCommandContext context) {

ActionReport notifiersReport = actionReport.addSubActionsReport();

List<ServiceHandle<BaseNotifierService>> allNotifierServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
List<ServiceHandle<BaseNotifierService>> allNotifierServiceHandles = serviceLocator.getAllServiceHandles(BaseNotifierService.class);

Properties notifierProps = new Properties();
if (!config.getNotifierList().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@
})
public class SetAdminAuditServiceNotifierConfiguration implements AdminCommand {

@Inject
private Target targetUtil;

@Inject
private ServerEnvironment server;

@Inject
private ConfigModularityUtils configModularityUtils;

@Inject
private AdminAuditService auditService;

@Param(name = "dynamic", optional = true, defaultValue = "false")
private Boolean dynamic;

Expand All @@ -135,6 +123,18 @@ public class SetAdminAuditServiceNotifierConfiguration implements AdminCommand {
private String notifierName;
private NotifierType notifierType;

@Inject
private Target targetUtil;

@Inject
private ServerEnvironment server;

@Inject
private ConfigModularityUtils configModularityUtils;

@Inject
private AdminAuditService auditService;

private ActionReport report;

private static final Logger LOGGER = Logger.getLogger(SetAdminAuditServiceNotifierConfiguration.class.getPackage().toString());
Expand Down

0 comments on commit 434e05c

Please sign in to comment.