Skip to content

Commit

Permalink
support server-side agent config files (#412)
Browse files Browse the repository at this point in the history
* agent downloads and overlays server-side config

* build platform mbeans and get attributes from them without the platform endpoint service being needed
  • Loading branch information
jmazzitelli authored and jshaughn committed Dec 18, 2017
1 parent b7bfadf commit 39cd3ab
Show file tree
Hide file tree
Showing 34 changed files with 857 additions and 4,127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.hawkular.agent.monitor.log.MsgLogger;
import org.hawkular.agent.monitor.protocol.dmr.DMRNodeLocation;
import org.hawkular.agent.monitor.protocol.jmx.JMXNodeLocation;
import org.hawkular.agent.monitor.protocol.platform.PlatformNodeLocation;

/**
* This represents the monitor service extension's XML configuration in a more consumable form.
Expand Down Expand Up @@ -268,6 +267,62 @@ public String getConfigFile() {
}
}

public static class PlatformConfiguration {

private final boolean enabled;
private final boolean memoryEnabled;
private final boolean fileStoresEnabled;
private final boolean processorsEnabled;
private final boolean powerSourcesEnabled;
private final String machineId;
private final String containerId;

public PlatformConfiguration(
boolean enabled,
boolean memoryEnabled,
boolean fileStoresEnabled,
boolean processorsEnabled,
boolean powerSourcesEnabled,
String machineId,
String containerId) {
this.enabled = enabled;
this.memoryEnabled = memoryEnabled;
this.fileStoresEnabled = fileStoresEnabled;
this.processorsEnabled = processorsEnabled;
this.powerSourcesEnabled = powerSourcesEnabled;
this.machineId = machineId;
this.containerId = containerId;
}

public boolean isEnabled() {
return enabled;
}

public boolean isMemoryEnabled() {
return memoryEnabled;
}

public boolean isFileStoresEnabled() {
return fileStoresEnabled;
}

public boolean isProcessorsEnabled() {
return processorsEnabled;
}

public boolean isPowerSourcesEnabled() {
return powerSourcesEnabled;
}

public String getMachineId() {
return machineId;
}

public String getContainerId() {
return containerId;
}
}

public static class ProtocolConfiguration<L> {

public static <L> Builder<L> builder() {
Expand Down Expand Up @@ -424,26 +479,37 @@ public Collection<Name> getResourceTypeSets() {
private final MetricsExporterConfiguration metricsExporterConfiguration;
private final DiagnosticsConfiguration diagnostics;
private final StorageAdapterConfiguration storageAdapter;
private final PlatformConfiguration platformConfiguration;
private final ProtocolConfiguration<DMRNodeLocation> dmrConfiguration;
private final ProtocolConfiguration<JMXNodeLocation> jmxConfiguration;
private final ProtocolConfiguration<PlatformNodeLocation> platformConfiguration;

public AgentCoreEngineConfiguration(
GlobalConfiguration globalConfiguration,
MetricsExporterConfiguration metricsExporterConfiguration,
DiagnosticsConfiguration diagnostics,
StorageAdapterConfiguration storageAdapter,
PlatformConfiguration platformConfiguration,
ProtocolConfiguration<DMRNodeLocation> dmrConfiguration,
ProtocolConfiguration<JMXNodeLocation> jmxConfiguration,
ProtocolConfiguration<PlatformNodeLocation> platformConfiguration) {
ProtocolConfiguration<JMXNodeLocation> jmxConfiguration) {
super();
this.globalConfiguration = globalConfiguration;
this.metricsExporterConfiguration = metricsExporterConfiguration;
this.diagnostics = diagnostics;
this.storageAdapter = storageAdapter;
this.platformConfiguration = platformConfiguration;
this.dmrConfiguration = dmrConfiguration;
this.jmxConfiguration = jmxConfiguration;
this.platformConfiguration = platformConfiguration;
}

public AgentCoreEngineConfiguration cloneWith(StorageAdapterConfiguration newStorageAdapter) {
return new AgentCoreEngineConfiguration(
globalConfiguration,
metricsExporterConfiguration,
diagnostics,
newStorageAdapter,
platformConfiguration,
dmrConfiguration,
jmxConfiguration);
}

public GlobalConfiguration getGlobalConfiguration() {
Expand All @@ -462,15 +528,8 @@ public DiagnosticsConfiguration getDiagnostics() {
return diagnostics;
}

public AgentCoreEngineConfiguration cloneWith(StorageAdapterConfiguration newStorageAdapter) {
return new AgentCoreEngineConfiguration(
globalConfiguration,
metricsExporterConfiguration,
diagnostics,
newStorageAdapter,
dmrConfiguration,
jmxConfiguration,
platformConfiguration);
public PlatformConfiguration getPlatformConfiguration() {
return platformConfiguration;
}

public ProtocolConfiguration<DMRNodeLocation> getDmrConfiguration() {
Expand All @@ -480,8 +539,4 @@ public ProtocolConfiguration<DMRNodeLocation> getDmrConfiguration() {
public ProtocolConfiguration<JMXNodeLocation> getJmxConfiguration() {
return jmxConfiguration;
}

public ProtocolConfiguration<PlatformNodeLocation> getPlatformConfiguration() {
return platformConfiguration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
import org.hawkular.agent.monitor.protocol.jmx.JMXEndpointService;
import org.hawkular.agent.monitor.protocol.jmx.JMXNodeLocation;
import org.hawkular.agent.monitor.protocol.jmx.JMXSession;
import org.hawkular.agent.monitor.protocol.platform.PlatformEndpointService;
import org.hawkular.agent.monitor.protocol.platform.PlatformNodeLocation;
import org.hawkular.agent.monitor.protocol.platform.PlatformSession;
import org.hawkular.agent.monitor.util.ThreadFactoryGenerator;

/**
Expand All @@ -64,7 +61,6 @@ public static class Builder {
private final String feedId;
private ProtocolService<DMRNodeLocation, DMRSession> dmrProtocolService;
private ProtocolService<JMXNodeLocation, JMXSession> jmxProtocolService;
private ProtocolService<PlatformNodeLocation, PlatformSession> platformProtocolService;
private final Map<String, SSLContext> sslContexts;
private final Diagnostics diagnostics;
private int autoDiscoveryScanPeriodSecs;
Expand All @@ -77,8 +73,7 @@ public Builder(String feedId, Map<String, SSLContext> sslContexts, Diagnostics d
}

public ProtocolServices build() {
return new ProtocolServices(dmrProtocolService, jmxProtocolService, platformProtocolService,
autoDiscoveryScanPeriodSecs);
return new ProtocolServices(dmrProtocolService, jmxProtocolService, autoDiscoveryScanPeriodSecs);
}

public Builder autoDiscoveryScanPeriodSecs(int periodSecs) {
Expand Down Expand Up @@ -159,38 +154,6 @@ public Builder jmxProtocolService(ProtocolConfiguration<JMXNodeLocation> protoco
this.jmxProtocolService = builder.build();
return this;
}

public Builder platformProtocolService(ProtocolConfiguration<PlatformNodeLocation> protocolConfig) {

ProtocolService.Builder<PlatformNodeLocation, PlatformSession> builder = ProtocolService
.builder("Platform");

for (EndpointConfiguration server : protocolConfig.getEndpoints().values()) {
if (server.isEnabled()) {
final String securityRealm = server.getSecurityRealm();
SSLContext sslContext = null;
if (securityRealm != null) {
sslContext = sslContexts.get(securityRealm);
if (sslContext == null) {
throw new IllegalArgumentException("Unknown security realm: " + securityRealm);
}
}
final MonitoredEndpoint<EndpointConfiguration> endpoint = MonitoredEndpoint
.<EndpointConfiguration> of(server, sslContext);
ResourceTypeManager<PlatformNodeLocation> resourceTypeManager = new ResourceTypeManager<>(
protocolConfig.getTypeSets().getResourceTypeSets(), server.getResourceTypeSets());
PlatformEndpointService endpointService = new PlatformEndpointService(feedId, endpoint,
resourceTypeManager, diagnostics.getPlatformDiagnostics());
builder.endpointService(endpointService);

log.debugf("[%s] created with resource type sets [%s]", endpointService,
server.getResourceTypeSets());
}
}

this.platformProtocolService = builder.build();
return this;
}
}

private static final MsgLogger log = AgentLoggers.getLogger(ProtocolServices.class);
Expand All @@ -201,7 +164,6 @@ public static Builder builder(String feedId, Diagnostics diagnostics, Map<String

private final ProtocolService<DMRNodeLocation, DMRSession> dmrProtocolService;
private final ProtocolService<JMXNodeLocation, JMXSession> jmxProtocolService;
private final ProtocolService<PlatformNodeLocation, PlatformSession> platformProtocolService;
private final List<ProtocolService<?, ?>> services;

// used to execute auto-discovery scans periodically
Expand All @@ -211,13 +173,10 @@ public static Builder builder(String feedId, Diagnostics diagnostics, Map<String
public ProtocolServices(
ProtocolService<DMRNodeLocation, DMRSession> dmrProtocolService,
ProtocolService<JMXNodeLocation, JMXSession> jmxProtocolService,
ProtocolService<PlatformNodeLocation, PlatformSession> platformProtocolService,
int autoDiscoveryScanPeriodSecs) {
this.dmrProtocolService = dmrProtocolService;
this.jmxProtocolService = jmxProtocolService;
this.platformProtocolService = platformProtocolService;
this.services = Collections.unmodifiableList(Arrays.asList(dmrProtocolService, jmxProtocolService,
platformProtocolService));
this.services = Collections.unmodifiableList(Arrays.asList(dmrProtocolService, jmxProtocolService));
this.autoDiscoveryScanPeriodSecs = autoDiscoveryScanPeriodSecs;
}

Expand Down Expand Up @@ -266,10 +225,6 @@ public ProtocolService<JMXNodeLocation, JMXSession> getJmxProtocolService() {
return jmxProtocolService;
}

public ProtocolService<PlatformNodeLocation, PlatformSession> getPlatformProtocolService() {
return platformProtocolService;
}

public List<ProtocolService<?, ?>> getServices() {
return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
* @author John Mazzitelli
*/
public interface Constants {
// this is a special resource config property on the platform OS resource itself
// these are special resource config properties on the platform OS resource itself
String MACHINE_ID = "Machine Id";

// this is a special resource config property on the platform OS resource itself
String CONTAINER_ID = "Container Id";
String OS_VERSION = "Version";

enum PlatformResourceType {
OPERATING_SYSTEM("Operating System"), //
Expand All @@ -50,7 +49,7 @@ enum PlatformResourceType {
private Collection<ID> metricTypeIds;

PlatformResourceType(String name) {
this.resourceTypeId = new ID("Platform_" + name);
this.resourceTypeId = new ID(name);
this.resourceTypeName = new Name(name);
}

Expand Down
Loading

0 comments on commit 39cd3ab

Please sign in to comment.