getNameSet() {
76 | return nameSet;
77 | }
78 |
79 | public boolean isEnabled() {
80 | return enabled;
81 | }
82 |
83 | public boolean isDisabledOrEmpty() {
84 | return !isEnabled() || nameSet == null || nameSet.isEmpty();
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/NamedObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | /**
20 | * An object that has an associated name as well as an ID.
21 | *
22 | * @author John Mazzitelli
23 | */
24 | public abstract class NamedObject extends IDObject {
25 | private final Name name;
26 |
27 | /**
28 | * Creates a named object.
29 | *
30 | * @param id the id of the object; if null, name will be used as its ID
31 | * @param name the name of the object; must not be null - typically this is determined
32 | * from the agent configuration as defined in the standalone.xml configuration.
33 | */
34 | public NamedObject(ID id, Name name) {
35 | super((id != null && !id.equals(ID.NULL_ID)) ? id : (name != null) ? new ID(name.getNameString()) : null);
36 |
37 | if (name == null) {
38 | throw new IllegalArgumentException("name cannot be null");
39 | }
40 | if (name.getNameString() == null) {
41 | throw new IllegalArgumentException("name string cannot be null");
42 | }
43 | this.name = name;
44 | }
45 |
46 | public Name getName() {
47 | return this.name;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/NodeLocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | import org.hawkular.agent.monitor.protocol.Driver;
20 |
21 | /**
22 | * Just a marker interface for protocol specific node locations. A node location should entail some protocol specific
23 | * object (call it a "path") that can be used to retrieve one or mode nodes using a protocol specific {@link Driver}.
24 | *
25 | * Note that platform specific paths
26 | *
27 | * - can be either relative to some other base path or absolute
28 | *
- can contain wildcards so that they can be used to retrieve a set of matching nodes.
29 | *
30 | * @author Peter Palaga
31 | */
32 | public interface NodeLocation {
33 | }
34 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/OperationParam.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | /**
20 | * Immutable object that describes a single operation parameter.
21 | *
22 | * @author hrupp
23 | */
24 | public class OperationParam {
25 |
26 | private final String name;
27 | private final String type;
28 | private final String description;
29 | private final String defaultValue;
30 | private final Boolean required;
31 |
32 | public OperationParam(String name, String type, String description, String defaultValue, Boolean required) {
33 | this.name = name;
34 | this.type = type;
35 | this.description = description;
36 | this.defaultValue = defaultValue;
37 | this.required = required;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public String getType() {
45 | return type;
46 | }
47 |
48 | public String getDescription() {
49 | return description;
50 | }
51 |
52 | public String getDefaultValue() {
53 | return defaultValue;
54 | }
55 |
56 | public Boolean isRequired() {
57 | return required;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | StringBuilder str = new StringBuilder("OperationParam: ");
63 | str.append("name=[").append(this.name);
64 | str.append("], type=[").append(this.type);
65 | str.append("], description=[").append(this.description);
66 | str.append("], defaultValue=[").append(this.defaultValue);
67 | str.append("], required=[").append(this.required);
68 | str.append("]");
69 | return str.toString();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ResourceConfigurationPropertyInstance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | /**
20 | * @author John Mazzitelli
21 | *
22 | * @param the type of the protocol specific location, typically a subclass of {@link NodeLocation}
23 | */
24 | public final class ResourceConfigurationPropertyInstance extends Instance> {
25 |
26 | private final String value;
27 |
28 | public ResourceConfigurationPropertyInstance(ID id, Name name, AttributeLocation attributeLocation,
29 | ResourceConfigurationPropertyType type, String value) {
30 | super(id, name, attributeLocation, type);
31 | this.value = value;
32 | }
33 |
34 | // copy-constructor
35 | public ResourceConfigurationPropertyInstance(ResourceConfigurationPropertyInstance original, boolean disown) {
36 | super(original, disown);
37 | this.value = original.value;
38 | }
39 |
40 | public String getValue() {
41 | return value;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return String.format("%s[value=%s]", super.toString(), getValue());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/ResourceConfigurationPropertyType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | /**
20 | * @author John Mazzitelli
21 | *
22 | * @param the type of the protocol specific location, typically a subclass of {@link NodeLocation}
23 | */
24 | public final class ResourceConfigurationPropertyType extends AttributeLocationProvider {
25 |
26 | public ResourceConfigurationPropertyType(ID id, Name name, AttributeLocation attributeLocation) {
27 | super(id, name, attributeLocation);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/inventory/SupportedMetricType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.hawkular.agent.monitor.inventory;
19 |
20 | /**
21 | * These are the different types of metrics supported by the metric storage system (Prometheus).
22 | */
23 | public enum SupportedMetricType {
24 | COUNTER, GAUGE, SUMMARY, HISTOGRAM;
25 | }
26 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/log/AgentLoggers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.log;
18 |
19 | import org.jboss.logging.Logger;
20 |
21 | /**
22 | * @author Peter Palaga
23 | */
24 | public final class AgentLoggers {
25 |
26 | public static MsgLogger getLogger(Class> clazz) {
27 | return Logger.getMessageLogger(MsgLogger.class, clazz.getName());
28 | }
29 |
30 | private AgentLoggers() {
31 | super();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/prometheus/WebServer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.prometheus;
18 |
19 | import java.io.File;
20 | import java.net.InetSocketAddress;
21 |
22 | import io.prometheus.client.CollectorRegistry;
23 | import io.prometheus.client.exporter.HTTPServer;
24 | import io.prometheus.client.hotspot.DefaultExports;
25 |
26 | public class WebServer {
27 |
28 | private HTTPServer server;
29 | private JmxCollector jmxCollector;
30 |
31 | public synchronized void start(String[] args) throws Exception {
32 | if (server != null) {
33 | return;
34 | }
35 |
36 | if (args.length < 2) {
37 | throw new Exception("Usage: WebServer <[hostname:]port> ");
38 | }
39 | String[] hostnamePort = args[0].split(":");
40 | int port;
41 | InetSocketAddress socket;
42 |
43 | if (hostnamePort.length == 2) {
44 | port = Integer.parseInt(hostnamePort[1]);
45 | socket = new InetSocketAddress(hostnamePort[0], port);
46 | } else {
47 | port = Integer.parseInt(hostnamePort[0]);
48 | socket = new InetSocketAddress(port);
49 | }
50 |
51 | jmxCollector = new JmxCollector(new File(args[1]));
52 | jmxCollector.register();
53 |
54 | DefaultExports.initialize();
55 | server = new HTTPServer(socket, CollectorRegistry.defaultRegistry, true); // true == daemon
56 | }
57 |
58 | public synchronized void stop() {
59 | if (server == null) {
60 | return;
61 | }
62 |
63 | try {
64 | CollectorRegistry.defaultRegistry.unregister(jmxCollector);
65 | server.stop();
66 | } finally {
67 | server = null;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/ProtocolException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.protocol;
18 |
19 | /**
20 | * Thrown on any problems related to the protocol specific access to resources.
21 | *
22 | * @author Peter Palaga
23 | */
24 | public class ProtocolException extends Exception {
25 | private static final long serialVersionUID = 1L;
26 |
27 | public ProtocolException() {
28 | }
29 |
30 | public ProtocolException(String message) {
31 | super(message);
32 | }
33 |
34 | public ProtocolException(Throwable cause) {
35 | super(cause);
36 | }
37 |
38 | public ProtocolException(String message, Throwable cause) {
39 | super(message, cause);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/dmr/DMRSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.protocol.dmr;
18 |
19 | import java.io.IOException;
20 |
21 | import org.hawkular.agent.monitor.inventory.MonitoredEndpoint;
22 | import org.hawkular.agent.monitor.inventory.ResourceTypeManager;
23 | import org.hawkular.agent.monitor.protocol.Driver;
24 | import org.hawkular.agent.monitor.protocol.LocationResolver;
25 | import org.hawkular.agent.monitor.protocol.Session;
26 | import org.jboss.as.controller.client.ModelControllerClient;
27 |
28 | /**
29 | * @author Peter Palaga
30 | * @see Session
31 | */
32 | public class DMRSession extends Session {
33 |
34 | private final ModelControllerClient client;
35 |
36 | public DMRSession(String feedId,
37 | MonitoredEndpoint endpoint,
38 | ResourceTypeManager resourceTypeManager,
39 | Driver driver,
40 | LocationResolver locationResolver,
41 | ModelControllerClient client) {
42 | super(feedId, endpoint, resourceTypeManager, driver, locationResolver);
43 | this.client = client;
44 | }
45 |
46 | /** @see java.io.Closeable#close() */
47 | @Override
48 | public void close() throws IOException {
49 | if (client != null) {
50 | client.close();
51 | }
52 | }
53 |
54 | /**
55 | * Returns a native client. Note that the returned client is valid only within the scope of this {@link DMRSession}
56 | * because it gets closed in {@link #close()}.
57 | *
58 | * @return a native client
59 | */
60 | public ModelControllerClient getClient() {
61 | return client;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/jmx/JMXDriver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.protocol.jmx;
18 |
19 | import javax.management.ObjectName;
20 |
21 | import org.hawkular.agent.monitor.diagnostics.ProtocolDiagnostics;
22 | import org.hawkular.agent.monitor.protocol.Driver;
23 |
24 | /**
25 | * Abstract JMX driver that both local and remote JMX drivers extend.
26 | *
27 | * @see Driver
28 | */
29 | public abstract class JMXDriver implements Driver {
30 |
31 | private final ProtocolDiagnostics diagnostics;
32 |
33 | public JMXDriver(ProtocolDiagnostics diagnostics) {
34 | this.diagnostics = diagnostics;
35 | }
36 |
37 | public abstract Object executeOperation(ObjectName objName, String opName, Object[] args, Class>[] signature)
38 | throws Exception;
39 |
40 | protected ProtocolDiagnostics getDiagnostics() {
41 | return diagnostics;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/jmx/JMXSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.protocol.jmx;
18 |
19 | import java.io.IOException;
20 |
21 | import org.hawkular.agent.monitor.inventory.MonitoredEndpoint;
22 | import org.hawkular.agent.monitor.inventory.ResourceTypeManager;
23 | import org.hawkular.agent.monitor.protocol.Driver;
24 | import org.hawkular.agent.monitor.protocol.LocationResolver;
25 | import org.hawkular.agent.monitor.protocol.Session;
26 |
27 | /**
28 | * A session for any JMX endpoint (local or remote)
29 | * @see Session
30 | */
31 | public class JMXSession
32 | extends Session {
33 |
34 | public JMXSession(String feedId,
35 | MonitoredEndpoint endpoint,
36 | ResourceTypeManager resourceTypeManager,
37 | Driver driver,
38 | LocationResolver locationResolver) {
39 | super(feedId, endpoint, resourceTypeManager, driver, locationResolver);
40 | }
41 |
42 | @Override
43 | public void close() throws IOException {
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/service/ServiceStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.service;
18 |
19 | /**
20 | * @author Peter Palaga
21 | */
22 | public enum ServiceStatus {
23 | INITIAL, STARTING, RUNNING, STOPPING, STOPPED;
24 |
25 | public void assertInitialOrStopped(Class> cl, String action) throws IllegalStateException {
26 | if (this != INITIAL && this != STOPPED) {
27 | throw new IllegalStateException("[" + cl.getName() + "] must be in state [" + INITIAL + "] or ["
28 | + STOPPED + "] rather than [" + this + "] to perform [" + action + "]");
29 | }
30 | }
31 |
32 | public void assertRunning(Class> cl, String action) throws IllegalStateException {
33 | if (this != RUNNING) {
34 | throw new IllegalStateException("[" + cl.getName() + "] must be in state [" + RUNNING + "] rather than ["
35 | + this + "] to perform [" + action + "]");
36 | }
37 | }
38 |
39 | /**
40 | * @return true if the service is stopped or will be stopped soon. Initial mode is considered stopped.
41 | */
42 | public boolean isStoppingOrStopped() {
43 | return this == STOPPING || this == STOPPED || this == INITIAL;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/storage/InventoryStorageProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.storage;
18 |
19 | import org.hawkular.agent.monitor.api.InventoryEvent;
20 | import org.hawkular.agent.monitor.api.InventoryStorage;
21 | import org.hawkular.agent.monitor.protocol.Session;
22 |
23 | /**
24 | * A proxy that delegates to a {@link StorageAdapter}.
25 | */
26 | public class InventoryStorageProxy implements InventoryStorage {
27 |
28 | private StorageAdapter storageAdapter;
29 |
30 | public InventoryStorageProxy() {
31 | }
32 |
33 | public void setStorageAdapter(StorageAdapter storageAdapter) {
34 | this.storageAdapter = storageAdapter;
35 | }
36 |
37 | @Override
38 | public > void receivedEvent(InventoryEvent event) {
39 | if (storageAdapter == null) {
40 | throw new IllegalStateException("Storage infrastructure is not ready yet");
41 | }
42 | storageAdapter.receivedEvent(event);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/storage/NotificationPayloadBuilderImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.storage;
18 |
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | import org.hawkular.agent.monitor.api.NotificationPayloadBuilder;
23 | import org.hawkular.client.api.Notification;
24 | import org.hawkular.client.api.NotificationType;
25 |
26 | public class NotificationPayloadBuilderImpl implements NotificationPayloadBuilder {
27 |
28 | private NotificationType notificationType;
29 | private Map properties = new HashMap<>();
30 |
31 | @Override
32 | public void addNotificationType(NotificationType notificationType) {
33 | this.notificationType = notificationType;
34 |
35 | }
36 |
37 | @Override
38 | public void addProperty(String name, String value) {
39 | properties.put(name, value);
40 | }
41 |
42 | @Override
43 | public Notification toPayload() {
44 | return new Notification(notificationType, properties);
45 | }
46 | }
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/storage/StorageAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.storage;
18 |
19 | import org.hawkular.agent.monitor.api.InventoryStorage;
20 | import org.hawkular.agent.monitor.api.NotificationStorage;
21 | import org.hawkular.agent.monitor.config.AgentCoreEngineConfiguration;
22 | import org.hawkular.agent.monitor.diagnostics.Diagnostics;
23 |
24 | public interface StorageAdapter extends InventoryStorage, NotificationStorage {
25 |
26 | /**
27 | * Initializes the storage adapter.
28 | *
29 | * @param feedId identifies the feed that is storing data
30 | * @param config the configuration of the storage adapter
31 | * @param diag the object used to track internal diagnostic data for the storage adapter
32 | * @param httpClientBuilder used to communicate with the storage server
33 | */
34 | void initialize(
35 | String feedId,
36 | AgentCoreEngineConfiguration.StorageAdapterConfiguration config,
37 | Diagnostics diag,
38 | HttpClientBuilder httpClientBuilder);
39 |
40 | /**
41 | * Clean up and stop whatever the storage adapter is doing.
42 | */
43 | void shutdown();
44 |
45 | /**
46 | * @return the storage adapter's configuration settings
47 | */
48 | AgentCoreEngineConfiguration.StorageAdapterConfiguration getStorageAdapterConfiguration();
49 | }
50 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/util/Consumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.util;
18 |
19 | public interface Consumer {
20 | void accept(T result);
21 | void report(Throwable e);
22 | }
--------------------------------------------------------------------------------
/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/util/ThreadFactoryGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.util;
18 |
19 | import java.lang.Thread.UncaughtExceptionHandler;
20 | import java.util.concurrent.ThreadFactory;
21 |
22 | import org.jboss.threads.JBossThreadFactory;
23 |
24 | /**
25 | * @author John Mazzitelli
26 | */
27 | public class ThreadFactoryGenerator {
28 | public static final ThreadFactory generateFactory(boolean daemon, String threadGroupName) {
29 | String namePattern = "%G-%t";
30 | UncaughtExceptionHandler uncaughtExceptionHandler = null;
31 | Integer initialPriority = null;
32 | Long stackSize = null;
33 | return new JBossThreadFactory(
34 | new ThreadGroup(threadGroupName),
35 | daemon,
36 | initialPriority,
37 | namePattern,
38 | uncaughtExceptionHandler,
39 | stackSize,
40 | null); // this last param is ignored according to docs.
41 | // see: https://github.com/jbossas/jboss-threads/blob/2.2/src/main/java/org/jboss/threads/JBossThreadFactory.java#L90
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/test/java/org/hawkular/agent/monitor/inventory/InventoryIdUtilTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.inventory;
18 |
19 | import java.util.Collections;
20 |
21 | import org.hawkular.agent.monitor.config.AgentCoreEngineConfiguration.EndpointConfiguration;
22 | import org.hawkular.agent.monitor.inventory.InventoryIdUtil.ResourceIdParts;
23 | import org.junit.Assert;
24 | import org.junit.Test;
25 |
26 | public class InventoryIdUtilTest {
27 |
28 | @Test
29 | public void testParsingResourceId() {
30 | ID id;
31 | ResourceIdParts parts;
32 |
33 | EndpointConfiguration endpointConfig = new EndpointConfiguration("testmanagedserver", true,
34 | Collections.emptyList(), null, null, null, null, null);
35 | MonitoredEndpoint me = MonitoredEndpoint. of(endpointConfig,
36 | null);
37 |
38 | id = InventoryIdUtil.generateResourceId("fid", me, "/test/id/path");
39 | Assert.assertEquals("fid~testmanagedserver~/test/id/path", id.toString());
40 | parts = InventoryIdUtil.parseResourceId(id.getIDString());
41 | Assert.assertEquals("fid", parts.getFeedId());
42 | Assert.assertEquals("testmanagedserver", parts.getManagedServerName());
43 | Assert.assertEquals("/test/id/path", parts.getIdPart());
44 |
45 | // test that you can have ~ in the last part of the ID
46 | id = InventoryIdUtil.generateResourceId("fid", me, "~/~test/~id/~path");
47 | Assert.assertEquals("fid~testmanagedserver~~/~test/~id/~path", id.toString());
48 | parts = InventoryIdUtil.parseResourceId(id.getIDString());
49 | Assert.assertEquals("fid", parts.getFeedId());
50 | Assert.assertEquals("testmanagedserver", parts.getManagedServerName());
51 | Assert.assertEquals("~/~test/~id/~path", parts.getIdPart());
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/hawkular-agent-core/src/test/java/org/hawkular/agent/monitor/protocol/dmr/DMREndpointServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.monitor.protocol.dmr;
18 |
19 | import static org.junit.Assert.assertEquals;
20 |
21 | import java.util.UUID;
22 |
23 | import org.junit.Test;
24 |
25 |
26 | /**
27 | * @author Peter Palaga
28 | *
29 | */
30 | public class DMREndpointServiceTest {
31 | @Test
32 | public void testServerId() {
33 |
34 | String id = DMREndpointService.getServerIdentifier("one", "two", "three", null);
35 | assertEquals("one.two.three", id);
36 |
37 | id = DMREndpointService.getServerIdentifier(null, "two", "three", null);
38 | assertEquals("two.three", id);
39 |
40 | id = DMREndpointService.getServerIdentifier(null, null, "three", null);
41 | assertEquals("three", id);
42 |
43 | id = DMREndpointService.getServerIdentifier(null, null, null, null);
44 | assertEquals("", id);
45 |
46 | id = DMREndpointService.getServerIdentifier("", "two", "three", null);
47 | assertEquals("two.three", id);
48 |
49 | id = DMREndpointService.getServerIdentifier("", "", "three", null);
50 | assertEquals("three", id);
51 |
52 | id = DMREndpointService.getServerIdentifier("", "", "", null);
53 | assertEquals("", id);
54 |
55 | // if server name and node name are the same, only one is added to the full ID
56 | id = DMREndpointService.getServerIdentifier("one", "two", "two", null);
57 | assertEquals("one.two", id);
58 |
59 | id = DMREndpointService.getServerIdentifier("", "two", "two", null);
60 | assertEquals("two", id);
61 |
62 | id = DMREndpointService.getServerIdentifier(null, "two", "two", null);
63 | assertEquals("two", id);
64 |
65 | String uuid = UUID.randomUUID().toString();
66 | id = DMREndpointService.getServerIdentifier("a", "b", "c", uuid);
67 | assertEquals(uuid, id);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/DmrApiException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | /**
20 | * @author Peter Palaga
21 | */
22 | public class DmrApiException extends RuntimeException {
23 | private static final long serialVersionUID = 1047518822601238146L;
24 |
25 | public DmrApiException(String message) {
26 | super(message);
27 | }
28 |
29 | public DmrApiException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 |
33 | public DmrApiException(Throwable cause) {
34 | super(cause);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/DmrApiLoggers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | import org.jboss.logging.Logger;
20 |
21 | /**
22 | * @author Peter Palaga
23 | */
24 | public final class DmrApiLoggers {
25 |
26 | public static MsgLogger getLogger(Class> clazz) {
27 | return Logger.getMessageLogger(MsgLogger.class, clazz.getName());
28 | }
29 |
30 | private DmrApiLoggers() {
31 | super();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/DmrUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | import java.util.StringTokenizer;
20 |
21 | import org.jboss.dmr.ModelNode;
22 |
23 | /**
24 | * @author Peter Palaga
25 | */
26 | public class DmrUtils {
27 | public static String toJavaStringLiteral(ModelNode node) {
28 | String in = node.toString();
29 | StringBuilder result = new StringBuilder(in.length() + in.length()/16);
30 | StringTokenizer st = new StringTokenizer(in, "\n\r");
31 | boolean first = true;
32 | while (st.hasMoreTokens()) {
33 | String line = st.nextToken();
34 | /* no newline character at the end of the last line */
35 | String newLine = st.hasMoreTokens() ? "\\n" : "";
36 | line = "\"" + line.replace("\"", "\\\"") + newLine + "\" //";
37 | if (first) {
38 | first = false;
39 | } else {
40 | line = "+ " + line;
41 | }
42 | result.append(line);
43 | }
44 | return result.toString();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/MsgLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | import org.jboss.logging.BasicLogger;
20 | import org.jboss.logging.Logger;
21 | import org.jboss.logging.annotations.MessageLogger;
22 | import org.jboss.logging.annotations.ValidIdRange;
23 |
24 | @MessageLogger(projectCode = "HAWKDMRCLIENT")
25 | @ValidIdRange(min = 10000, max = 19999)
26 | public interface MsgLogger extends BasicLogger {
27 | MsgLogger LOG = Logger.getMessageLogger(MsgLogger.class, "org.hawkular.dmr");
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/OperationFailureException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | /**
20 | * @author Peter Palaga
21 | */
22 | public class OperationFailureException extends DmrApiException {
23 | private static final long serialVersionUID = -8120364704766408172L;
24 |
25 | public OperationFailureException(String message, Throwable cause) {
26 | super(message, cause);
27 | }
28 |
29 | public OperationFailureException(String message) {
30 | super(message);
31 | }
32 |
33 | public OperationFailureException(Throwable cause) {
34 | super(cause);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/SubsystemDatasourceConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | /**
20 | * Constants specific to datasources subsystem.
21 | *
22 | * @author Peter Palaga
23 | */
24 | public interface SubsystemDatasourceConstants {
25 | public interface DatasourceNodeCommonConstants {
26 | String DRIVER_NAME = "driver-name";
27 | String JNDI_NAME = "jndi-name";
28 | String NAME = "name";
29 | String PASSWORD = "password";
30 | String USER_NAME = "user-name";
31 | String STATISTICS_ENABLED = "statistics-enabled";
32 | }
33 |
34 | public interface DatasourceNodeConstants extends DatasourceNodeCommonConstants {
35 | String CONNECTION_URL = "connection-url";
36 | String DRIVER_CLASS = "driver-class";
37 | }
38 |
39 | public interface XaDatasourceNodeConstants extends DatasourceNodeCommonConstants {
40 | String SECURITY_DOMAIN = "security-domain";
41 | String XA_DATASOURCE_CLASS = "xa-datasource-class";
42 | }
43 |
44 | public interface JdbcDriverNodeConstants {
45 | String DRIVER_NAME = "driver-name";
46 | String DRIVER_CLASS_NAME = "driver-class-name";
47 | String DRIVER_MODULE_NAME = "driver-module-name";
48 | String DRIVER_MAJOR_VERSION = "driver-major-version";
49 | String DRIVER_MINOR_VERSION = "driver-minor-version";
50 | String DRIVER_XA_DATASOURCE_CLASS_NAME = "driver-xa-datasource-class-name";
51 | String JDBC_COMPLIANT = "jdbc-compliant";
52 | }
53 |
54 | String CONNECTION_PROPERTIES = "connection-properties";
55 | String DATASOURCE = "data-source";
56 | String DATASOURCES = "datasources";
57 |
58 | String JDBC_DRIVER = "jdbc-driver";
59 | String XA_DATASOURCE = "xa-data-source";
60 |
61 | String XA_DATASOURCE_PROPERTIES = "xa-datasource-properties";
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmr/api/SubsystemLoggingConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmr.api;
18 |
19 | /**
20 | * Constants specific to logging subsystem.
21 | *
22 | * @author Peter Palaga
23 | */
24 | public interface SubsystemLoggingConstants {
25 | String LOGGING = "logging";
26 | String LOGGER = "logger";
27 | interface LoggerNodeConstants {
28 | String CATEGORY = "category";
29 | String LEVEL = "level";
30 | String USE_PARENT_HANDLERS = "use-parent-handlers";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/FailureException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmrclient;
18 |
19 | import org.jboss.dmr.ModelNode;
20 |
21 | /**
22 | * Indicates a failed client request.
23 | *
24 | * @author John Mazzitelli
25 | */
26 | public class FailureException extends RuntimeException {
27 | private static final long serialVersionUID = 1L;
28 |
29 | private static final String GENERIC_ERROR = "Failed request";
30 |
31 | public FailureException(ModelNode failureNode) {
32 | super(buildErrorMessage(GENERIC_ERROR, failureNode));
33 | }
34 |
35 | public FailureException(ModelNode failureNode, String errMsg) {
36 | super(buildErrorMessage(errMsg, failureNode));
37 | }
38 |
39 | public FailureException(ModelNode failureNode, Throwable cause) {
40 | super(buildErrorMessage(GENERIC_ERROR, failureNode), cause);
41 | }
42 |
43 | public FailureException(ModelNode failureNode, String errMsg, Throwable cause) {
44 | super(buildErrorMessage(errMsg, failureNode), cause);
45 | }
46 |
47 | public FailureException(String errMsg, Throwable cause) {
48 | super((errMsg != null) ? errMsg : GENERIC_ERROR, cause);
49 | }
50 |
51 | public FailureException(String errMsg) {
52 | super((errMsg != null) ? errMsg : GENERIC_ERROR);
53 | }
54 |
55 | public FailureException(Throwable cause) {
56 | super(GENERIC_ERROR, cause);
57 | }
58 |
59 | public FailureException() {
60 | super(GENERIC_ERROR);
61 | }
62 |
63 | private static String buildErrorMessage(String errMsg, ModelNode failureNode) {
64 | if (errMsg == null) {
65 | errMsg = GENERIC_ERROR;
66 | }
67 |
68 | String description = JBossASClient.getFailureDescription(failureNode);
69 | if (description != null) {
70 | errMsg += ": " + description;
71 | }
72 |
73 | return errMsg;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/TransactionsJBossASClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.dmrclient;
18 |
19 | import org.jboss.as.controller.client.ModelControllerClient;
20 | import org.jboss.dmr.ModelNode;
21 |
22 | /**
23 | * Provides management of the transactions subsystem.
24 | *
25 | * @author John Mazzitelli
26 | */
27 | public class TransactionsJBossASClient extends JBossASClient {
28 |
29 | public static final String TRANSACTIONS = "transactions";
30 |
31 | public TransactionsJBossASClient(ModelControllerClient client) {
32 | super(client);
33 | }
34 |
35 | /**
36 | * Sets the default transaction timeout.
37 | * @param timeoutSecs the new default transaction timeout, in seconds.
38 | * @throws Exception any error
39 | */
40 | public void setDefaultTransactionTimeout(int timeoutSecs) throws Exception {
41 | final Address address = Address.root().add(SUBSYSTEM, TRANSACTIONS);
42 | final ModelNode req = createWriteAttributeRequest("default-timeout", String.valueOf(timeoutSecs), address);
43 | final ModelNode response = execute(req);
44 |
45 | if (!isSuccess(response)) {
46 | throw new FailureException(response);
47 | }
48 | return;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/test/resources/org/hawkular/dmrclient/modules/complicated.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/test/resources/org/hawkular/dmrclient/modules/minimal.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/hawkular-dmr-client/src/test/resources/org/hawkular/dmrclient/modules/usual.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-cmdgw-itest/server-provisioning.xml:
--------------------------------------------------------------------------------
1 |
19 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-cmdgw-itest/src/test/java/org/hawkular/agent/ws/test/ExportJdrCommandITest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.ws.test;
18 |
19 | import org.hawkular.cmdgw.ws.test.TestWebSocketClient;
20 | import org.hawkular.inventory.api.model.Resource;
21 | import org.jboss.as.controller.client.ModelControllerClient;
22 | import org.testng.annotations.Test;
23 |
24 | /**
25 | * @author Juraci Paixão Kröhling
26 | */
27 | public class ExportJdrCommandITest extends AbstractCommandITest {
28 | public static final String GROUP = "ExportJdrCommandITest";
29 |
30 | @Test(groups = { GROUP }, dependsOnGroups = { StandaloneDeployApplicationITest.GROUP })
31 | public void exportJdrCommand() throws Throwable {
32 | waitForHawkularServerToBeReady();
33 |
34 | Resource wfResource = getHawkularWildFlyServerResource();
35 |
36 | try (ModelControllerClient ignored = newHawkularModelControllerClient()) {
37 | String req = "ExportJdrRequest={\"authentication\":" + authentication + ", "
38 | + "\"feedId\":\"" + wfResource.getFeedId() + "\","
39 | + "\"resourceId\":\"" + wfResource.getId() + "\""
40 | + "}";
41 | String responsePattern = "\\QExportJdrResponse={\\E.*";
42 | try (TestWebSocketClient testClient = TestWebSocketClient.builder()
43 | .url(baseGwUri + "/ui/ws")
44 | .readTimeout(240)//seconds
45 | .expectWelcome(req)
46 | .expectGenericSuccess(wfResource.getFeedId())
47 | .expectBinary(responsePattern, new TestWebSocketClient.ZipWithOneEntryMatcher(), TestWebSocketClient.Answer.CLOSE)
48 | .expectClose()
49 | .build()) {
50 | /* 240 seconds, as JDR takes long to execute */
51 | testClient.validate(240_000);
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-cmdgw-itest/src/test/resources/logging.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | handlers=java.util.logging.ConsoleHandler
19 | java.util.logging.ConsoleHandler.level=DEBUG
20 |
21 | .level=DEBUG
22 | org.hawkular.cmdgw.ws.test.TestWebSocketClient.level = DEBUG
23 | org.hawkular.cmdgw.ws.test.AbstractCommandITest.level = DEBUG
24 | org.hawkular.cmdgw.ws.test.StandaloneDeployApplicationITest.level = DEBUG
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-cmdgw-itest/src/test/resources/org/hawkular/agent/ws/test/JdbcDriverCommandITest.driver-after-add.node.txt:
--------------------------------------------------------------------------------
1 | {
2 | "deployment-name" => undefined,
3 | "driver-class-name" => "com.mysql.jdbc.Driver",
4 | "driver-datasource-class-name" => undefined,
5 | "driver-major-version" => 5,
6 | "driver-minor-version" => 1,
7 | "driver-module-name" => "com.mysql",
8 | "driver-name" => "mysql",
9 | "driver-xa-datasource-class-name" => "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource",
10 | "jdbc-compliant" => true,
11 | "module-slot" => undefined,
12 | "profile" => undefined,
13 | "xa-datasource-class" => undefined
14 | }
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-domain-itest/server-provisioning-hawkular.xml:
--------------------------------------------------------------------------------
1 |
19 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-domain-itest/server-provisioning-plain-wildfly.xml:
--------------------------------------------------------------------------------
1 |
19 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-domain-itest/src/test/java/org/hawkular/agent/test/AbstractDomainITestSuite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.test;
18 |
19 | import org.hawkular.javaagent.itest.util.AbstractITest;
20 | import org.testng.annotations.AfterSuite;
21 | import org.testng.annotations.BeforeSuite;
22 | import org.testng.annotations.Test;
23 |
24 | @Test(suiteName = AbstractDomainITestSuite.SUITE)
25 | public class AbstractDomainITestSuite extends AbstractITest {
26 | public static final String SUITE = "domain";
27 |
28 | @BeforeSuite
29 | public void beforeSuiteWaitForHawkularServerToBeReady() throws Throwable {
30 | System.out.println("STARTING JAVAAGENT DOMAIN ITESTS");
31 | }
32 |
33 | @AfterSuite(alwaysRun = true)
34 | public void afterDomainITestSuite() throws Throwable {
35 | System.out.println("FINISHED JAVAAGENT DOMAIN ITESTS");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/hawkular-javaagent-domain-itest/src/test/resources/logging.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | handlers=java.util.logging.ConsoleHandler
19 | java.util.logging.ConsoleHandler.level=FINEST
20 |
21 | .level=INFO
22 | org.hawkular.cmdgw.ws.test.TestWebSocketClient.level = FINEST
23 | org.hawkular.cmdgw.ws.test.AbstractCommandITest.level = FINEST
24 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-all-itests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.hawkular.agent
25 | hawkular-javaagent-itest-parent
26 | 2.0.0.Alpha1-SNAPSHOT
27 |
28 |
29 | hawkular-javaagent-all-itests
30 | pom
31 |
32 | Hawkular Agent: Parent of All Integration Tests
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | hawkular-javaagent-cmdgw-itest
42 | hawkular-javaagent-domain-itest
43 |
44 |
45 |
46 |
47 | itest.debug
48 |
49 |
50 | itest.debug
51 |
52 |
53 |
54 | -Xrunjdwp:transport=dt_socket,address=5007,server=y,suspend=y
55 | -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
56 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.hawkular.agent
25 | hawkular-javaagent-itest-parent
26 | 2.0.0.Alpha1-SNAPSHOT
27 |
28 |
29 | hawkular-javaagent-helloworld-war
30 | war
31 |
32 | Hawkular Agent: Hello World WAR
33 | A simple web application for testing purposes
34 |
35 |
36 |
37 |
38 | javax.enterprise
39 | cdi-api
40 | provided
41 |
42 |
43 |
44 | org.jboss.spec.javax.servlet
45 | jboss-servlet-api_3.1_spec
46 | provided
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.apache.maven.plugins
55 | maven-checkstyle-plugin
56 |
57 | **/SimpleMXBeanImpl.java
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/java/org/hawkular/agent/helloworld/HelloWorldServlet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.hawkular.agent.helloworld;
19 |
20 | import java.io.IOException;
21 | import java.io.PrintWriter;
22 |
23 | import javax.inject.Inject;
24 | import javax.servlet.ServletConfig;
25 | import javax.servlet.ServletException;
26 | import javax.servlet.annotation.WebServlet;
27 | import javax.servlet.http.HttpServlet;
28 | import javax.servlet.http.HttpServletRequest;
29 | import javax.servlet.http.HttpServletResponse;
30 |
31 | @WebServlet(value = "/HelloWorld", loadOnStartup = 1)
32 | public class HelloWorldServlet extends HttpServlet {
33 | private static final long serialVersionUID = 1L;
34 |
35 | @Inject
36 | private SimpleMXBeanImpl mbean;
37 |
38 | @Override
39 | public void init(ServletConfig config) throws ServletException {
40 | super.init(config);
41 | mbean.setTestInteger(0);
42 | log("Test MBean has been registered: " + SimpleMXBeanImpl.OBJECT_NAME);
43 | }
44 |
45 | @Override
46 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
47 | Integer num = Integer.valueOf(mbean.getTestInteger().intValue() + 1);
48 | mbean.setTestInteger(num);
49 | resp.setContentType("text/html");
50 | PrintWriter writer = resp.getWriter();
51 | writer.println("helloworld");
52 | writer.println(mbean.getTestString());
53 | writer.println(" #");
54 | writer.println(num);
55 | writer.println("
");
56 | writer.close();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/java/org/hawkular/agent/helloworld/SimpleMXBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.hawkular.agent.helloworld;
19 |
20 | import javax.management.MXBean;
21 |
22 | @MXBean
23 | public interface SimpleMXBean {
24 |
25 | // JMX Attributes
26 |
27 | String getTestString();
28 |
29 | int getTestIntegerPrimitive();
30 | Integer getTestInteger();
31 | void setTestInteger(Integer i);
32 |
33 | boolean getTestBooleanPrimitive();
34 | Boolean getTestBoolean();
35 |
36 | long getTestLongPrimitive();
37 | Long getTestLong();
38 |
39 | double getTestDoublePrimitive();
40 | Double getTestDouble();
41 |
42 | float getTestFloatPrimitive();
43 | Float getTestFloat();
44 |
45 | short getTestShortPrimitive();
46 | Short getTestShort();
47 |
48 | char getTestCharPrimitive();
49 | Character getTestChar();
50 |
51 | byte getTestBytePrimitive();
52 | Byte getTestByte();
53 |
54 | // JMX Operations
55 |
56 | void testOperationNoParams();
57 | String testOperationPrimitive(String s, int i, boolean b, long l, double d, float f, short h, char c, byte y);
58 | String testOperation(String s, Integer i, Boolean b, Long l, Double d, Float f, Short h, Character c, Byte y);
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/webapp/WEB-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
26 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/webapp/WEB-INF/jboss-web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 | /hawkular/helloworld
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
22 |
23 |
24 | index.html
25 |
26 |
27 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-helloworld-war/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/assembly.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
22 |
23 | ${project.artifactId}
24 |
25 | zip
26 |
27 | false
28 |
29 |
30 | target/${project.artifactId}-${project.version}
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/feature-pack-build.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/src/main/xsl/configuration/standalone/hawkular-javaagent-itest-subsystems.xsl:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | hawkular-javaagent-itest-messaging-activemq.xml
27 |
28 |
29 |
30 |
31 | hawkular-javaagent-itest-logging.xml
32 |
33 |
34 |
35 |
36 |
37 | hawkular-javaagent-itest-infinispan.xml
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/src/main/xsl/subsystem-templates/hawkular-javaagent-itest-infinispan.xsl:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/src/main/xsl/subsystem-templates/hawkular-javaagent-itest-logging.xsl:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-feature-pack/src/main/xsl/subsystem-templates/hawkular-javaagent-itest-messaging-activemq.xsl:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/hawkular-javaagent-itest-util/src/main/java/org/hawkular/javaagent/itest/util/WildFlyClientConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.hawkular.javaagent.itest.util;
19 |
20 | /**
21 | * Returns information about a plain wildfly that has been setup for the tests.
22 | */
23 | public class WildFlyClientConfig {
24 | private final String wfHost;
25 | private final int wfManagementPort;
26 |
27 | public WildFlyClientConfig() {
28 | wfHost = System.getProperty("plain-wildfly.bind.address");
29 | wfManagementPort = Integer.parseInt(System.getProperty("plain-wildfly.management.http.port"));
30 | if (wfHost == null) {
31 | throw new RuntimeException("Plain WildFly Server system properties are not set");
32 | }
33 | }
34 |
35 | public String getHost() {
36 | return wfHost;
37 | }
38 |
39 | public int getManagementPort() {
40 | return wfManagementPort;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/hawkular-javaagent-itest-parent/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | 4.0.0
22 |
23 |
24 | org.hawkular.agent
25 | hawkular-wildfly-agent-parent
26 | 2.0.0.Alpha1-SNAPSHOT
27 |
28 |
29 | hawkular-javaagent-itest-parent
30 | pom
31 |
32 | Hawkular Agent: Javaagent Integration Tests Parent
33 |
34 |
35 | hawkular-javaagent-helloworld-war
36 | hawkular-javaagent-itest-feature-pack
37 | hawkular-javaagent-itest-util
38 | hawkular-javaagent-all-itests
39 |
40 |
41 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-dist/assembly.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
23 |
24 | dist
25 |
26 | zip
27 |
28 | false
29 |
30 |
31 | target
32 |
33 |
34 | ${project.build.finalName}/**
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-dist/server-provisioning-plain-wildfly.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-feature-pack/assembly.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
23 |
24 | hawkular-javaagent-wildfly-feature-pack
25 |
26 | zip
27 |
28 | false
29 |
30 |
31 | target/hawkular-javaagent-wildfly-feature-pack-${project.version}
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-feature-pack/feature-pack-build.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-feature-pack/src/main/resources/featurepack/content/standalone/configuration/hawkular-javaagent-config-metrics-only.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: "${hawkular.agent.enabled:true}"
21 |
22 | metrics-exporter:
23 | enabled: true
24 | host: ${hawkular.agent.metrics.host,jboss.bind.address:127.0.0.1}
25 | port: ${hawkular.agent.metrics.port:9779}
26 | config-dir: ${jboss.server.config.dir}
27 | config-file: WF10
28 | proxy:
29 | mode: slave
30 | data-dir: ${jboss.server.data.dir}/hawkular-metrics-exporter
31 |
32 | storage-adapter:
33 | feed-id: "${hawkular.rest.feedId:autogenerate}"
34 | url: "${hawkular.rest.url:http://hawkular-server:8080}"
35 | username: "${env.HAWKULAR_USER,hawkular.rest.username}"
36 | password: "${env.HAWKULAR_PASSWORD,hawkular.rest.password}"
37 |
38 | platform:
39 | enabled: true
40 | #machine-id: my-machine-id-here
41 |
--------------------------------------------------------------------------------
/hawkular-javaagent-wildfly-feature-pack/src/main/resources/featurepack/content/standalone/configuration/hawkular-javaagent-config.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: "${hawkular.agent.enabled:true}"
21 | immutable: "${hawkular.agent.immutable:false}"
22 | in-container: "${hawkular.agent.in-container:false}"
23 | auto-discovery-scan-period-secs: ${hawkular.agent.auto-discovery-scan-period-secs:600}
24 | type-version: WF10
25 |
26 | metrics-exporter:
27 | enabled: true
28 | host: ${hawkular.agent.metrics.host,jboss.bind.address:127.0.0.1}
29 | port: ${hawkular.agent.metrics.port:9779}
30 | config-dir: ${jboss.server.config.dir}
31 | config-file: WF10
32 | proxy:
33 | mode: disabled
34 | data-dir: ${jboss.server.data.dir}/hawkular-metrics-exporter
35 |
36 | diagnostics:
37 | enabled: true
38 | interval: 1
39 | time-units: minutes
40 |
41 | storage-adapter:
42 | feed-id: "${hawkular.rest.feedId:autogenerate}"
43 | url: "${hawkular.rest.url:http://hawkular-server:8080}"
44 | username: "${env.HAWKULAR_USER,hawkular.rest.username}"
45 | password: "${env.HAWKULAR_PASSWORD,hawkular.rest.password}"
46 |
47 | # MANAGED SERVERS
48 |
49 | managed-servers:
50 | local-dmr:
51 | name: Local DMR
52 | enabled: true
53 | wait-for:
54 | - name: /
55 | metric-labels:
56 | feed_id: "%FeedId"
57 |
58 | local-jmx:
59 | name: Local JMX
60 | enabled: true
61 | wait-for:
62 | - name: java.lang:type=Runtime
63 | metric-labels:
64 | feed_id: "%FeedId"
65 |
66 | remote-dmr:
67 | - name: Remote DMR
68 | enabled: false
69 | host: 127.0.0.1
70 | port: 9990
71 | username: adminUser
72 | password: adminPass
73 | wait-for:
74 | - name: /
75 | metric-labels:
76 | feed_id: "%FeedId"
77 |
78 | platform:
79 | enabled: true
80 | #machine-id: my-machine-id-here
81 |
--------------------------------------------------------------------------------
/hawkular-javaagent/README.adoc:
--------------------------------------------------------------------------------
1 | = Hawkular Java Agent
2 |
3 | This provides a Java Agent that can be installed in any VM via the -javaagent command line argument.
4 |
5 | == Running in your application
6 |
7 | To attach the Hawkular Java Agent to your running application's VM, pass the following option to your Java application's command line:
8 |
9 | ```
10 | -javaagent:hawkular-javaagent-shaded-*.jar=config=hawkular-javaagent-config.yaml,delay=10"
11 | ```
12 |
13 | Of course, make sure the path names point to the correct Hawkular Java Agent jar and its configuration file. The `delay` option tells the agent to delay its start up the given number of seconds. This is useful to give your main application time to start up before the agent starts monitoring it.
14 |
15 | == Running in WildFly or EAP
16 |
17 | It is recommended you copy the Hawkular Java Agent jar to the WildFly/EAP `bin/` directory and its configuration file to the `standalone/configuration` directory, but their locations really do not matter so long as you refer to their proper file paths in the `-javaagent` command line argument (e.g. `-javaagent:=config=,delay=10`).
18 |
19 | Due to the way the logging implementations are loaded, you must change your WildFly/EAP server configuration slightly:
20 |
21 | `standalone.conf`:
22 |
23 | ```
24 | # Hawkular Java Agent: Add "org.jboss.logmanager" to the JBoss Modules system packages
25 | if [ "x$JBOSS_MODULES_SYSTEM_PKGS" = "x" ]; then
26 | JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"
27 | fi
28 |
29 | # Hawkular Java Agent:
30 | # Explicitly tell the VM to use the JBoss Log Manager via -Djava.util.logging.manager system property.
31 | # Use the -javaagent VM option to load the Hawkular Java Agent with its config file.
32 | JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:$JBOSS_HOME/bin/hawkular-javaagent-*.jar=config=$JBOSS_HOME/standalone/configuration/hawkular-javaagent-config.yaml,delay=10"
33 | ```
34 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/JavaAgentMXBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent;
18 |
19 | import javax.management.MXBean;
20 |
21 | @MXBean
22 | public interface JavaAgentMXBean {
23 |
24 | // JMX Attributes
25 |
26 | String getVersion();
27 |
28 | boolean getImmutable();
29 |
30 | boolean getInContainer();
31 |
32 | String getMetricsEndpoints();
33 |
34 | // JMX Operations
35 | void start();
36 |
37 | void stop();
38 |
39 | String status();
40 |
41 | String fullDiscoveryScan();
42 |
43 | String inventoryReport();
44 | }
45 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/Util.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent;
18 |
19 | import java.lang.reflect.Array;
20 | import java.lang.reflect.Constructor;
21 |
22 | public final class Util {
23 |
24 | /**
25 | * Performs a deep copy of the given array by calling a copy constructor to build clones of each array element.
26 | */
27 | @SuppressWarnings("unchecked")
28 | public static T[] cloneArray(T[] original) {
29 | if (original == null) {
30 | return null;
31 | }
32 |
33 | try {
34 | Class> clazz = original.getClass().getComponentType();
35 | T[] copy = (T[]) Array.newInstance(clazz, original.length);
36 | if (copy.length != 0) {
37 | Constructor copyConstructor = (Constructor) clazz.getConstructor(clazz);
38 | int i = 0;
39 | for (T t : original) {
40 | copy[i++] = copyConstructor.newInstance(t);
41 | }
42 | }
43 | return copy;
44 | } catch (Exception e) {
45 | throw new RuntimeException("Cannot copy array. Does its type have a copy-constructor? " + original, e);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/cmd/EchoCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.cmd;
18 |
19 | import org.hawkular.agent.monitor.cmd.Command;
20 | import org.hawkular.agent.monitor.cmd.CommandContext;
21 | import org.hawkular.bus.common.BasicMessageWithExtraData;
22 | import org.hawkular.cmdgw.api.EchoRequest;
23 | import org.hawkular.cmdgw.api.EchoResponse;
24 |
25 | /**
26 | * A dummy command placeholder.
27 | */
28 | public class EchoCommand
29 | implements Command {
30 |
31 | public static final Class REQUEST_CLASS = EchoRequest.class;
32 |
33 | public EchoCommand() {
34 | }
35 |
36 |
37 | @Override
38 | public BasicMessageWithExtraData execute(
39 | BasicMessageWithExtraData envelope,
40 | CommandContext context)
41 | throws Exception {
42 |
43 | // we can cast this because we know our command implementation is only ever installed in a JavaAgentEngine
44 | // JavaAgentEngine javaAgent = (JavaAgentEngine) context.getAgentCoreEngine();
45 | // Configuration javaAgentConfig = javaAgent.getConfigurationManager().getConfiguration();
46 |
47 | EchoResponse echoResp = new EchoResponse();
48 | echoResp.setReply("ECHO:" + envelope.getBasicMessage().getEchoMessage());
49 | return new BasicMessageWithExtraData(echoResp, null);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/AbstractExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package org.hawkular.agent.javaagent.config;
19 |
20 | /**
21 | * If a YAML property supports expressions (that is, can have ${x} tokens in its value), the
22 | * property type is going to be a subclass of this.
23 | */
24 | public abstract class AbstractExpression extends AbstractStringifiedProperty {
25 |
26 | public AbstractExpression() {
27 | super();
28 | }
29 |
30 | public AbstractExpression(T defaultVal) {
31 | super(defaultVal);
32 | }
33 |
34 | public AbstractExpression(String expr) {
35 | super(expr);
36 | }
37 |
38 | public AbstractExpression(AbstractExpression original) {
39 | super(original);
40 | }
41 |
42 | @Override
43 | public T get() {
44 | String valueAsString = StringPropertyReplacer.replaceProperties(super.getValueAsString());
45 | return deserialize(valueAsString);
46 | }
47 |
48 | @Override
49 | protected String serialize(T value) {
50 | return value != null ? value.toString() : "";
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/BooleanExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | /**
20 | * The type of any YAML property that is a boolean
21 | * but whose YAML representation can include ${x} expressions.
22 | */
23 | public class BooleanExpression extends AbstractExpression {
24 | public BooleanExpression() {
25 | super();
26 | }
27 |
28 | public BooleanExpression(Boolean initialValue) {
29 | super(initialValue);
30 | }
31 |
32 | public BooleanExpression(String expression) {
33 | super(expression);
34 | }
35 |
36 | // copy-constructor
37 | public BooleanExpression(BooleanExpression original) {
38 | super(original);
39 | }
40 |
41 | @Override
42 | protected Boolean deserialize(String valueAsString) {
43 | // make sure the value is either true or false - anything else is an error
44 | if (valueAsString == null) {
45 | throw new IllegalArgumentException("Boolean expression was null");
46 | } else if (valueAsString.equalsIgnoreCase("true")) {
47 | return Boolean.TRUE;
48 | } else if (valueAsString.equalsIgnoreCase("false")) {
49 | return Boolean.FALSE;
50 | } else {
51 | throw new IllegalArgumentException("Boolean expression was neither true nor false: " + valueAsString);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/Diagnostics.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
20 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
21 | import com.fasterxml.jackson.annotation.JsonProperty;
22 |
23 | @JsonAutoDetect( //
24 | fieldVisibility = Visibility.NONE, //
25 | getterVisibility = Visibility.NONE, //
26 | setterVisibility = Visibility.NONE, //
27 | isGetterVisibility = Visibility.NONE)
28 | public class Diagnostics implements Validatable {
29 |
30 | @JsonProperty
31 | private Boolean enabled = Boolean.TRUE;
32 |
33 | @JsonProperty
34 | private Integer interval = 5;
35 |
36 | @JsonProperty("time-units")
37 | private TimeUnits timeUnits = TimeUnits.minutes;
38 |
39 | public Diagnostics() {
40 | }
41 |
42 | public Diagnostics(Diagnostics original) {
43 | this.enabled = original.enabled;
44 | this.interval = original.interval;
45 | this.timeUnits = original.timeUnits;
46 | }
47 |
48 | @Override
49 | public void validate() throws Exception {
50 | if (interval == null || interval.intValue() < 0) {
51 | throw new Exception("diagnostics interval must be greater than or equal to 0");
52 | }
53 | }
54 |
55 | public Boolean getEnabled() {
56 | return enabled;
57 | }
58 |
59 | public void setEnabled(Boolean enabled) {
60 | this.enabled = enabled;
61 | }
62 |
63 | public Integer getInterval() {
64 | return interval;
65 | }
66 |
67 | public void setInterval(Integer interval) {
68 | this.interval = interval;
69 | }
70 |
71 | public TimeUnits getTimeUnits() {
72 | return timeUnits;
73 | }
74 |
75 | public void setTimeUnits(TimeUnits timeUnits) {
76 | this.timeUnits = timeUnits;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/IntegerExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | /**
20 | * The type of any YAML property that is an integer
21 | * but whose YAML representation can include ${x} expressions.
22 | */
23 | public class IntegerExpression extends AbstractExpression {
24 | public IntegerExpression() {
25 | super();
26 | }
27 |
28 | public IntegerExpression(Integer initialValue) {
29 | super(initialValue);
30 | }
31 |
32 | public IntegerExpression(String expression) {
33 | super(expression);
34 | }
35 |
36 | // copy-constructor
37 | public IntegerExpression(IntegerExpression original) {
38 | super(original);
39 | }
40 |
41 | @Override
42 | protected Integer deserialize(String valueAsString) {
43 | try {
44 | return Integer.valueOf(valueAsString);
45 | } catch (Exception e) {
46 | throw new IllegalArgumentException("Integer expression could not be evaluated to a valid number", e);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/MetricTypeJsonProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import java.util.Locale;
20 |
21 | import org.hawkular.agent.monitor.inventory.SupportedMetricType;
22 |
23 | public class MetricTypeJsonProperty extends AbstractStringifiedProperty {
24 | public MetricTypeJsonProperty() {
25 | super();
26 | }
27 |
28 | public MetricTypeJsonProperty(SupportedMetricType initialValue) {
29 | super(initialValue);
30 | }
31 |
32 | public MetricTypeJsonProperty(String valueAsString) {
33 | super(valueAsString);
34 | }
35 |
36 | public MetricTypeJsonProperty(MetricTypeJsonProperty original) {
37 | super(original);
38 | }
39 |
40 | @Override
41 | protected SupportedMetricType deserialize(String valueAsString) {
42 | if (valueAsString != null) {
43 | return SupportedMetricType.valueOf(valueAsString.toUpperCase(Locale.ENGLISH));
44 | } else {
45 | throw new IllegalArgumentException("Metric type is not specified");
46 | }
47 | }
48 |
49 | @Override
50 | protected String serialize(SupportedMetricType value) {
51 | if (value != null) {
52 | return value.name().toLowerCase();
53 | } else {
54 | throw new IllegalArgumentException("Metric type is not specified");
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/MetricUnitJsonProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import java.util.Locale;
20 |
21 | import org.hawkular.inventory.api.model.MetricUnit;
22 |
23 | public class MetricUnitJsonProperty extends AbstractStringifiedProperty {
24 | public MetricUnitJsonProperty() {
25 | super();
26 | }
27 |
28 | public MetricUnitJsonProperty(MetricUnit initialValue) {
29 | super(initialValue);
30 | }
31 |
32 | public MetricUnitJsonProperty(String valueAsString) {
33 | super(valueAsString);
34 | }
35 |
36 | public MetricUnitJsonProperty(MetricUnitJsonProperty original) {
37 | super(original);
38 | }
39 |
40 | @Override
41 | protected MetricUnit deserialize(String valueAsString) {
42 | if (valueAsString != null) {
43 | return MetricUnit.valueOf(valueAsString.toUpperCase(Locale.ENGLISH));
44 | } else {
45 | throw new IllegalArgumentException("Measurement units not specified");
46 | }
47 | }
48 |
49 | @Override
50 | protected String serialize(MetricUnit value) {
51 | if (value != null) {
52 | return value.name().toLowerCase();
53 | } else {
54 | throw new IllegalArgumentException("Metric type is not specified");
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/StringExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import org.hawkular.agent.javaagent.config.StringExpression.StringValue;
20 |
21 | /**
22 | * The type of any YAML property that is a string
23 | * but whose YAML representation can include ${x} expressions.
24 | */
25 | public class StringExpression extends AbstractExpression {
26 | public StringExpression() {
27 | super();
28 | }
29 |
30 | public StringExpression(StringValue initialValue) {
31 | super(initialValue);
32 | }
33 |
34 | public StringExpression(String expression) {
35 | super(expression);
36 | }
37 |
38 | // copy-constructor
39 | public StringExpression(StringExpression original) {
40 | super(original);
41 | }
42 |
43 | @Override
44 | protected StringValue deserialize(String valueAsString) {
45 | return new StringValue(valueAsString);
46 | }
47 |
48 | // we need a type to distinguish from String so our constructor signatures don't clash
49 | public static class StringValue {
50 | private final String value;
51 |
52 | public StringValue(String value) {
53 | this.value = value;
54 | }
55 |
56 | public String toString() {
57 | return this.value;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/TimeUnits.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import java.util.concurrent.TimeUnit;
20 |
21 | public enum TimeUnits {
22 | milliseconds, seconds, minutes;
23 |
24 | public java.util.concurrent.TimeUnit toJavaTimeUnit() {
25 | switch (this) {
26 | case milliseconds:
27 | return TimeUnit.MILLISECONDS;
28 | case seconds:
29 | return TimeUnit.SECONDS;
30 | case minutes:
31 | return TimeUnit.MINUTES;
32 | default:
33 | throw new IllegalStateException("Invalid enum - cannot convert: " + this);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/Validatable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | /**
20 | * Objects that can have their state checked for correctness implement this interface.
21 | */
22 | public interface Validatable {
23 | /**
24 | * Checks the state of the object to ensure it is valid.
25 | *
26 | * @throws Exception if the state of the object is not valid
27 | */
28 | void validate() throws Exception;
29 | }
30 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/WaitFor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
20 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
21 | import com.fasterxml.jackson.annotation.JsonProperty;
22 |
23 | @JsonAutoDetect( //
24 | fieldVisibility = Visibility.NONE, //
25 | getterVisibility = Visibility.NONE, //
26 | setterVisibility = Visibility.NONE, //
27 | isGetterVisibility = Visibility.NONE)
28 | public class WaitFor implements Validatable {
29 |
30 | @JsonProperty(required = true)
31 | private String name;
32 |
33 | public WaitFor() {
34 | }
35 |
36 | public WaitFor(WaitFor original) {
37 | this.name = original.name;
38 | }
39 |
40 | @Override
41 | public void validate() throws Exception {
42 | if (name == null || name.trim().isEmpty()) {
43 | throw new Exception("wait-for name must be specified");
44 | }
45 | }
46 |
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | public void setName(String name) {
52 | this.name = name;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/log/JavaAgentLoggers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.log;
18 |
19 | import org.jboss.logging.Logger;
20 |
21 | public final class JavaAgentLoggers {
22 | public static MsgLogger getLogger(Class> clazz) {
23 | return Logger.getMessageLogger(MsgLogger.class, clazz.getName());
24 | }
25 |
26 | private JavaAgentLoggers() {
27 | super();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/log/MsgLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.log;
18 |
19 | import org.jboss.logging.BasicLogger;
20 | import org.jboss.logging.Logger;
21 | import org.jboss.logging.Logger.Level;
22 | import org.jboss.logging.annotations.Cause;
23 | import org.jboss.logging.annotations.LogMessage;
24 | import org.jboss.logging.annotations.Message;
25 | import org.jboss.logging.annotations.MessageLogger;
26 | import org.jboss.logging.annotations.ValidIdRange;
27 |
28 | @MessageLogger(projectCode = "HAWKJAVAAGENT")
29 | @ValidIdRange(min = 10000, max = 19999)
30 | public interface MsgLogger extends BasicLogger {
31 | MsgLogger LOG = Logger.getMessageLogger(MsgLogger.class, "org.hawkular.agent.javaagent");
32 |
33 | @LogMessage(level = Level.INFO)
34 | @Message(id = 10000, value = "Loaded configuration file [%s]")
35 | void infoLoadedConfigurationFile(String filepath);
36 |
37 | @LogMessage(level = Level.ERROR)
38 | @Message(id = 10001, value = "Error in security realm [%s]")
39 | void errorBuildingSecurityRealm(String securityRealmName, @Cause Throwable cause);
40 | }
41 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/java/org/hawkular/agent/javaagent/config/UtilTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | * and other contributors as indicated by the @author tags.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.hawkular.agent.javaagent.config;
18 |
19 | import org.hawkular.agent.javaagent.Util;
20 | import org.junit.Assert;
21 | import org.junit.Test;
22 |
23 | public class UtilTest {
24 |
25 | public static class ClassWithCopyConstructor {
26 | private int number = 0;
27 | private String string = "";
28 |
29 | public ClassWithCopyConstructor(int n, String s) {
30 | this.number = n;
31 | this.string = s;
32 | }
33 |
34 | public ClassWithCopyConstructor(ClassWithCopyConstructor original) {
35 | this.number = original.number;
36 | this.string = original.string;
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return "" + number + ":" + string;
42 | }
43 | }
44 |
45 | @Test
46 | public void testCloneArray() throws Exception {
47 | Assert.assertNull(Util.cloneArray(null));
48 | Assert.assertEquals(0, Util.cloneArray(new ClassWithCopyConstructor[0]).length);
49 |
50 | ClassWithCopyConstructor[] arr = new ClassWithCopyConstructor[3];
51 | arr[0] = new ClassWithCopyConstructor(1, "one");
52 | arr[1] = new ClassWithCopyConstructor(2, "two");
53 | arr[2] = new ClassWithCopyConstructor(3, "three");
54 | ClassWithCopyConstructor[] dup = Util.cloneArray(arr);
55 | Assert.assertEquals(arr.length, dup.length);
56 | Assert.assertNotSame(arr, dup);
57 | for (int i = 0; i < arr.length; i++) {
58 | Assert.assertEquals(arr[i].toString(), dup[i].toString());
59 | Assert.assertNotSame(arr[i], dup[i]);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/all-resource-type-sets.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | storage-adapter:
23 | url: http://127.0.0.1:8080
24 | username: jdoe
25 | password: password
26 |
27 | resource-type-set-dmr:
28 | - name: dmr type set 1
29 | resource-type-dmr:
30 | - name: dmr type 1
31 | path: /dmr-type=1
32 | - name: dmr type 2
33 | path: /dmr-type=2
34 | - name: dmr type set 2
35 | resource-type-dmr:
36 | - name: dmr type 3
37 | path: /dmr-type=3
38 | - name: dmr type 4
39 | path: /dmr-type=4
40 | - name: dmr type set X DISABLED
41 | enabled: false
42 | resource-type-dmr:
43 | - name: dmr type X
44 | path: /dmr-type=X
45 |
46 | resource-type-set-jmx:
47 | - name: jmx type set 1
48 | resource-type-jmx:
49 | - name: jmx type 1
50 | object-name: domain:type=one
51 | resource-name-template: name1
52 | - name: jmx type 2
53 | object-name: domain:type=two
54 | resource-name-template: name2
55 | - name: jmx type set 2
56 | resource-type-jmx:
57 | - name: jmx type 3
58 | object-name: domain:type=three
59 | resource-name-template: name3
60 | - name: jmx type 4
61 | object-name: domain:type=four
62 | resource-name-template: name4
63 | - name: jmx type set X DISABLED
64 | enabled: false
65 | resource-type-jmx:
66 | - name: jmx type X
67 | object-name: domain:type=X
68 | resource-name-template: nameX
69 |
70 | # No resource type set names are provided in managed server definitions.
71 | # The default is to include all of them if none are specified.
72 | managed-servers:
73 | local-dmr:
74 | name: local-dmr-ms
75 |
76 | remote-dmr:
77 | - name: remote-dmr-ms-1
78 | host: host1
79 | port: 1111
80 | - name: remote-dmr-ms-2
81 | host: host2
82 | port: 2222
83 |
84 | local-jmx:
85 | name: local-jmx-ms
86 |
87 | remote-jmx:
88 | - name: remote-jmx-ms-1
89 | url: http://host1
90 | - name: remote-jmx-ms-2
91 | url: http://host2
92 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/bad-notif.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | storage-adapter:
23 | url: http://127.0.0.1:8080
24 | username: jdoe
25 | password: password
26 |
27 | resource-type-set-dmr:
28 | - name: resource type set
29 | resource-type-dmr:
30 | - name: first resource type
31 | notification-dmr:
32 | - name: resource-added
33 | - name: not-valid
34 |
35 | managed-servers:
36 | local-dmr:
37 | name: Test
38 | resource-type-sets:
39 | - resource type set
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/empty.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # This is an empty but valid configuration file.
19 |
20 | subsystem:
21 | type-version: empty
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/test-overlay-all-resource-types-1.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | # DMR
23 |
24 | metric-set-dmr:
25 | - name: new metric set dmr
26 | metric-dmr:
27 | - name: new metric dmr
28 | attribute: attrib
29 | metric-family: new_metric_dmr
30 |
31 | resource-type-set-dmr:
32 | - name: new resource type set dmr
33 | resource-type-dmr:
34 | - name: new resource type dmr
35 | path: /new=new
36 | resource-name-template: new dmr
37 | metric-sets:
38 | - new metric set dmr
39 |
40 | - name: new not enabled set dmr
41 | enabled: false
42 | resource-type-dmr:
43 | - name: new not enabled dmr
44 | path: /
45 | resource-name-template: not enabled
46 |
47 | # JMX
48 |
49 | metric-set-jmx:
50 | - name: new metric set jmx
51 | metric-jmx:
52 | - name: new metric jmx
53 | attribute: attrib
54 | metric-family: new_metric_jmx
55 |
56 | resource-type-set-jmx:
57 | - name: new resource type set jmx
58 | resource-type-jmx:
59 | - name: new resource type jmx
60 | object-name: domain:metric=new
61 | resource-name-template: new jmx
62 | metric-sets:
63 | - new metric set jmx
64 |
65 | - name: new not enabled set jmx
66 | enabled: false
67 | resource-type-jmx:
68 | - name: new not enabled jmx
69 | object-name: domain:metric=notenabled
70 | resource-name-template: not enabled
71 |
72 | # MANAGED SERVERS
73 |
74 | managed-servers:
75 | local-dmr:
76 | name: Test Local DMR
77 | enabled: true
78 |
79 | local-jmx:
80 | name: Test Local JMX
81 | enabled: true
82 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/test-overlay-all-resource-types-2.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | # DMR
23 |
24 | metric-set-dmr:
25 | - name: original metric set dmr
26 | metric-dmr:
27 | - name: original metric dmr
28 | attribute: attrib
29 | metric-family: original_metric_dmr
30 |
31 | resource-type-set-dmr:
32 | - name: original resource type set dmr
33 | resource-type-dmr:
34 | - name: original resource type dmr
35 | path: /orig=orig
36 | resource-name-template: original dmr
37 | metric-sets:
38 | - original metric set dmr
39 |
40 | - name: original not enabled set dmr
41 | enabled: false
42 | resource-type-dmr:
43 | - name: original not enabled dmr
44 | path: /
45 | resource-name-template: not enabled
46 |
47 | # JMX
48 |
49 | metric-set-jmx:
50 | - name: original metric set jmx
51 | metric-jmx:
52 | - name: original metric jmx
53 | attribute: attrib
54 | metric-family: original_metric_jmx
55 |
56 | resource-type-set-jmx:
57 | - name: original resource type set jmx
58 | resource-type-jmx:
59 | - name: original resource type jmx
60 | object-name: domain:metric=orig
61 | resource-name-template: original jmx
62 | metric-sets:
63 | - original metric set jmx
64 |
65 | - name: original not enabled set jmx
66 | enabled: false
67 | resource-type-jmx:
68 | - name: original not enabled jmx
69 | object-name: domain:metric=notenabled
70 | resource-name-template: not enabled
71 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/test-overlay1.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | # DMR
23 |
24 | metric-set-dmr:
25 | - name: original metric set dmr
26 | metric-dmr:
27 | - name: original metric dmr
28 | attribute: attrib
29 | metric-family: original_metric_dmr
30 |
31 | resource-type-set-dmr:
32 | - name: original resource type set dmr
33 | resource-type-dmr:
34 | - name: original resource type dmr
35 | path: /orig=orig
36 | resource-name-template: original dmr
37 | metric-sets:
38 | - original metric set dmr
39 |
40 | # JMX
41 |
42 | metric-set-jmx:
43 | - name: original metric set jmx
44 | metric-jmx:
45 | - name: original metric jmx
46 | attribute: attrib
47 | metric-family: original_metric_jmx
48 |
49 | resource-type-set-jmx:
50 | - name: original resource type set jmx
51 | resource-type-jmx:
52 | - name: original resource type jmx
53 | object-name: domain:metric=orig
54 | resource-name-template: original jmx
55 | metric-sets:
56 | - original metric set jmx
57 |
58 | # MANAGED SERVERS
59 |
60 | managed-servers:
61 | local-dmr:
62 | name: Test Local DMR
63 | enabled: true
64 | resource-type-sets:
65 | - original metric set dmr
66 |
67 | local-jmx:
68 | name: Test Local JMX
69 | enabled: true
70 | resource-type-sets:
71 | - original metric set jmx
72 |
--------------------------------------------------------------------------------
/hawkular-javaagent/src/test/resources/test-overlay2.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
3 | # and other contributors as indicated by the @author tags.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | ---
19 | subsystem:
20 | enabled: true
21 |
22 | # DMR
23 |
24 | metric-set-dmr:
25 | - name: new metric set dmr
26 | metric-dmr:
27 | - name: new metric dmr
28 | attribute: attrib
29 | metric-family: new_metric_dmr
30 |
31 | resource-type-set-dmr:
32 | - name: new resource type set dmr
33 | resource-type-dmr:
34 | - name: new resource type dmr
35 | path: /new=new
36 | resource-name-template: original dmr
37 | metric-sets:
38 | - new metric set dmr
39 |
40 | # JMX
41 |
42 | metric-set-jmx:
43 | - name: new metric set jmx
44 | metric-jmx:
45 | - name: new metric jmx
46 | attribute: attrib
47 | metric-family: new_metric_jmx
48 |
49 | resource-type-set-jmx:
50 | - name: new resource type set jmx
51 | resource-type-jmx:
52 | - name: new resource type jmx
53 | object-name: domain:metric=new
54 | resource-name-template: original jmx
55 | metric-sets:
56 | - new metric set jmx
57 |
58 | # MANAGED SERVERS
59 |
60 | managed-servers:
61 | local-dmr:
62 | name: Test Local DMR
63 | enabled: true
64 | resource-type-sets:
65 | - new metric set dmr
66 |
67 | local-jmx:
68 | name: Test Local JMX
69 | enabled: true
70 | resource-type-sets:
71 | - new metric set jmx
72 |
--------------------------------------------------------------------------------