You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/02/17 13:00:16 UTC
[1/3] syncope git commit: bootstrap-select not used by console
Repository: syncope
Updated Branches:
refs/heads/master 411b7cf2e -> 3f0f25623
bootstrap-select not used by console
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/fbc3cfbd
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/fbc3cfbd
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/fbc3cfbd
Branch: refs/heads/master
Commit: fbc3cfbdfe89d21dd3250d80f65714cfe31b7601
Parents: 411b7cf
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Feb 16 17:19:15 2016 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Feb 16 17:19:15 2016 +0100
----------------------------------------------------------------------
deb/console/LICENSE | 5 -----
deb/console/NOTICE | 6 ------
2 files changed, 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/fbc3cfbd/deb/console/LICENSE
----------------------------------------------------------------------
diff --git a/deb/console/LICENSE b/deb/console/LICENSE
index 384add2..1adf5b7 100644
--- a/deb/console/LICENSE
+++ b/deb/console/LICENSE
@@ -694,11 +694,6 @@ This is licensed under the terms of the MIT license, see above.
==
-For Bootstrap-select (https://silviomoreto.github.io/bootstrap-select/):
-This is licensed under the terms of the MIT license, see above.
-
-==
-
For Font Awesome (https://fortawesome.github.io/Font-Awesome/icons/):
This is licensed under the terms of the MIT license, see above.
http://git-wip-us.apache.org/repos/asf/syncope/blob/fbc3cfbd/deb/console/NOTICE
----------------------------------------------------------------------
diff --git a/deb/console/NOTICE b/deb/console/NOTICE
index e422d63..db5579b 100644
--- a/deb/console/NOTICE
+++ b/deb/console/NOTICE
@@ -69,12 +69,6 @@ http://twitter.github.com/bootstrap/
==
-This products includes software developed by bootstrap-select.
-Copyright (C) 2013-2015 bootstrap-select.
-https://silviomoreto.github.io/bootstrap-select/
-
-==
-
This products includes software developed by Font Awesome.
https://fortawesome.github.io/Font-Awesome/icons/
[2/3] syncope git commit: [SYNCOPE-744] Fixing ChartJS appearance
Posted by il...@apache.org.
[SYNCOPE-744] Fixing ChartJS appearance
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/79834f92
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/79834f92
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/79834f92
Branch: refs/heads/master
Commit: 79834f92aa7a00b703568232f5593b44c2f714b5
Parents: fbc3cfb
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Feb 17 11:22:57 2016 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Feb 17 11:27:08 2016 +0100
----------------------------------------------------------------------
.../client/console/widgets/AbstractWidget.java | 4 ----
.../client/console/widgets/AnyByRealmWidget.java | 14 ++++++++++++--
.../syncope/client/console/widgets/LoadWidget.java | 9 +++++++--
.../client/console/widgets/UsersByStatusWidget.java | 4 +++-
.../client/console/widgets/AnyByRealmWidget.html | 4 +++-
.../syncope/client/console/widgets/LoadWidget.html | 4 +++-
.../client/console/widgets/UsersByStatusWidget.html | 4 +++-
7 files changed, 31 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/java/org/apache/syncope/client/console/widgets/AbstractWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AbstractWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AbstractWidget.java
index efe363b..a31acca 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AbstractWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AbstractWidget.java
@@ -24,10 +24,6 @@ public abstract class AbstractWidget extends Panel {
private static final long serialVersionUID = -4186604985011430091L;
- protected static final int MEDIUM_WIDTH = 451;
-
- protected static final int MEDIUM_HEIGHT = 227;
-
public AbstractWidget(final String id) {
super(id);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
index c4ddf51..0b3caa1 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/AnyByRealmWidget.java
@@ -70,9 +70,19 @@ public class AnyByRealmWidget extends AbstractWidget {
}
Bar bar = new Bar();
- bar.getData().setLabels(labels);
+ bar.getOptions().setScaleBeginAtZero(true);
+ bar.getOptions().setScaleShowGridLines(true);
+ bar.getOptions().setScaleGridLineWidth(1);
+ bar.getOptions().setBarShowStroke(true);
+ bar.getOptions().setBarStrokeWidth(2);
+ bar.getOptions().setBarValueSpacing(5);
+ bar.getOptions().setBarDatasetSpacing(1);
+ bar.getOptions().setResponsive(true);
+ bar.getOptions().setMaintainAspectRatio(true);
bar.getOptions().setMultiTooltipTemplate("<%= datasetLabel %> - <%= value %>");
+ bar.getData().setLabels(labels);
+
List<BarDataSet> datasets = new ArrayList<>();
LabeledBarDataSet userDataSet = new LabeledBarDataSet(userValues);
userDataSet.setFillColor("orange");
@@ -96,7 +106,7 @@ public class AnyByRealmWidget extends AbstractWidget {
}
bar.getData().setDatasets(datasets);
- add(new BarChartPanel("chart", Model.of(bar), MEDIUM_WIDTH, MEDIUM_HEIGHT));
+ add(new BarChartPanel("chart", Model.of(bar)));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
index f565a25..eeb4e64 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
@@ -47,17 +47,22 @@ public class LoadWidget extends AbstractWidget {
}
Line line = new Line();
- line.getData().setLabels(labels);
+ line.getOptions().setPointDot(false);
line.getOptions().setDatasetFill(false);
+ line.getOptions().setResponsive(true);
+ line.getOptions().setMaintainAspectRatio(true);
line.getOptions().setShowScale(false);
line.getOptions().setMultiTooltipTemplate("<%= datasetLabel %>");
+ line.getData().setLabels(labels);
+
List<LineDataSet> datasets = new ArrayList<>();
LineDataSet cpuDataSet = new LineDataSet(cpuValues);
cpuDataSet.setLabel("CPU");
cpuDataSet.setPointColor("purple");
cpuDataSet.setStrokeColor("purple");
datasets.add(cpuDataSet);
+
LineDataSet memDataSet = new LineDataSet(memValues);
memDataSet.setLabel("MEM");
memDataSet.setPointColor("grey");
@@ -65,7 +70,7 @@ public class LoadWidget extends AbstractWidget {
datasets.add(memDataSet);
line.getData().setDatasets(datasets);
- add(new LineChartPanel("chart", Model.of(line), MEDIUM_WIDTH, MEDIUM_HEIGHT));
+ add(new LineChartPanel("chart", Model.of(line)));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
index d395bfa..b36d927 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/UsersByStatusWidget.java
@@ -33,6 +33,8 @@ public class UsersByStatusWidget extends AbstractWidget {
super(id);
Doughnut doughnut = new Doughnut();
+ doughnut.getOptions().setResponsive(true);
+ doughnut.getOptions().setMaintainAspectRatio(true);
int i = 0;
for (Map.Entry<String, Integer> entry : usersByStatus.entrySet()) {
@@ -40,7 +42,7 @@ public class UsersByStatusWidget extends AbstractWidget {
i++;
}
- add(new DoughnutChartPanel("chart", Model.of(doughnut), MEDIUM_WIDTH, MEDIUM_HEIGHT));
+ add(new DoughnutChartPanel("chart", Model.of(doughnut)));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/resources/org/apache/syncope/client/console/widgets/AnyByRealmWidget.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/AnyByRealmWidget.html b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/AnyByRealmWidget.html
index a3631df..7a8e1f5 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/AnyByRealmWidget.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/AnyByRealmWidget.html
@@ -26,7 +26,9 @@ under the License.
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
- <div class="box-body" wicket:id="chart"/>
+ <div class="box-body">
+ <div class="chart" wicket:id="chart"/>
+ </div>
</div>
</div>
</wicket:panel>
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
index 6f89e7a..45c5d29 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
@@ -26,7 +26,9 @@ under the License.
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
- <div class="box-body" wicket:id="chart"/>
+ <div class="box-body">
+ <div class="chart" wicket:id="chart"/>
+ </div>
</div>
</div>
</wicket:panel>
http://git-wip-us.apache.org/repos/asf/syncope/blob/79834f92/client/console/src/main/resources/org/apache/syncope/client/console/widgets/UsersByStatusWidget.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/UsersByStatusWidget.html b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/UsersByStatusWidget.html
index db93105..0cdfd1f 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/UsersByStatusWidget.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/UsersByStatusWidget.html
@@ -26,7 +26,9 @@ under the License.
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
- <div class="box-body" wicket:id="chart"/>
+ <div class="box-body">
+ <div class="chart" wicket:id="chart"/>
+ </div>
</div>
</div>
</wicket:panel>
[3/3] syncope git commit: [SYNCOPE-744][SYNCOPE-750] Moving load
information reporting to a Quartz Job,
scheduled every minute to ensure consistency under load
Posted by il...@apache.org.
[SYNCOPE-744][SYNCOPE-750] Moving load information reporting to a Quartz Job, scheduled every minute to ensure consistency under load
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/3f0f2562
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/3f0f2562
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/3f0f2562
Branch: refs/heads/master
Commit: 3f0f25623ad682e19dcf86d0f5962e3f884b79e6
Parents: 79834f9
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Feb 17 13:00:06 2016 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Feb 17 13:00:06 2016 +0100
----------------------------------------------------------------------
.../client/console/topology/Topology.java | 5 +-
.../topology/TopologyWebSocketBehavior.java | 209 +++++++++++++++++++
.../console/topology/WebSocketBehavior.java | 208 ------------------
.../client/console/widgets/LoadWidget.java | 7 +-
.../client/console/widgets/LoadWidget.html | 10 +
.../syncope/common/lib/info/SystemInfo.java | 18 +-
.../apache/syncope/core/logic/SyncopeLogic.java | 58 ++---
.../core/logic/SystemLoadReporterJob.java | 58 +++++
.../core/logic/init/JobInstanceLoaderImpl.java | 38 +++-
9 files changed, 358 insertions(+), 253 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
index 01a369c..efc77a6 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java
@@ -89,8 +89,7 @@ public class Topology extends BasePage {
@Override
protected List<ResourceTO> load() {
- final List<ResourceTO> result = resourceRestClient.getAll();
- return result;
+ return resourceRestClient.getAll();
}
};
@@ -170,7 +169,7 @@ public class Topology extends BasePage {
}
});
- body.add(new WebSocketBehavior());
+ body.add(new TopologyWebSocketBehavior());
togglePanel = new TopologyTogglePanel("toggle", getPageReference());
body.add(togglePanel);
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyWebSocketBehavior.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyWebSocketBehavior.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyWebSocketBehavior.java
new file mode 100644
index 0000000..3f37984
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyWebSocketBehavior.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.topology;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import org.apache.syncope.client.console.rest.ConnectorRestClient;
+import org.apache.syncope.client.console.rest.ResourceRestClient;
+import org.apache.syncope.common.lib.to.ConnInstanceTO;
+import org.apache.syncope.common.lib.to.ResourceTO;
+import org.apache.wicket.Application;
+import org.apache.wicket.Session;
+import org.apache.wicket.ThreadContext;
+import org.apache.wicket.protocol.ws.api.WebSocketBehavior;
+import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
+import org.apache.wicket.protocol.ws.api.message.TextMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TopologyWebSocketBehavior extends WebSocketBehavior {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(TopologyWebSocketBehavior.class);
+
+ private static final long serialVersionUID = -1653665542635275551L;
+
+ private final Map<String, String> resources = new HashMap<>();
+
+ private final Set<String> runningResCheck = new HashSet<>();
+
+ private final Map<Long, String> connectors = new HashMap<>();
+
+ private final Set<Long> runningConnCheck = new HashSet<>();
+
+ private final ConnectorRestClient connectorRestClient = new ConnectorRestClient();
+
+ private final ResourceRestClient resourceRestClient = new ResourceRestClient();
+
+ @Override
+ protected void onMessage(final WebSocketRequestHandler handler, final TextMessage message) {
+ try {
+ final ObjectMapper mapper = new ObjectMapper();
+ final JsonNode obj = mapper.readTree(message.getText());
+
+ final ExecutorService executorService = Executors.newFixedThreadPool(1);
+
+ switch (Topology.SupportedOperation.valueOf(obj.get("kind").asText())) {
+ case CHECK_CONNECTOR:
+ final Long ckey = obj.get("target").asLong();
+
+ if (connectors.containsKey(ckey)) {
+ handler.push(connectors.get(ckey));
+ } else {
+ handler.push(String.format(
+ "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, ckey));
+ }
+
+ synchronized (runningConnCheck) {
+ if (runningConnCheck.contains(ckey)) {
+ LOG.debug("Running connection check for connector {}", ckey);
+ } else {
+ runningConnCheck.add(ckey);
+ }
+ }
+
+ executorService.execute(new ConnCheck(ckey));
+
+ break;
+ case CHECK_RESOURCE:
+ final String rkey = obj.get("target").asText();
+
+ if (resources.containsKey(rkey)) {
+ handler.push(resources.get(rkey));
+ } else {
+ handler.push(String.format(
+ "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, rkey));
+ }
+
+ synchronized (runningResCheck) {
+ if (runningResCheck.contains(rkey)) {
+ LOG.debug("Running connection check for resource {}", rkey);
+ } else {
+ runningResCheck.add(rkey);
+ }
+ }
+
+ executorService.execute(new ResCheck(rkey));
+
+ break;
+ case ADD_ENDPOINT:
+ handler.appendJavaScript(String.format("addEndpoint('%s', '%s', '%s');",
+ obj.get("source").asText(),
+ obj.get("target").asText(),
+ obj.get("scope").asText()));
+ break;
+ default:
+ }
+
+ executorService.shutdown();
+
+ } catch (IOException e) {
+ LOG.error("Eror managing websocket message", e);
+ }
+ }
+
+ class ConnCheck implements Runnable {
+
+ private final Long key;
+
+ private final Application application;
+
+ private final Session session;
+
+ ConnCheck(final Long key) {
+ this.key = key;
+ this.application = Application.get();
+ this.session = Session.exists() ? Session.get() : null;
+ }
+
+ @Override
+ public void run() {
+ try {
+ ThreadContext.setApplication(application);
+ ThreadContext.setSession(session);
+
+ String res;
+ try {
+ final ConnInstanceTO connector = connectorRestClient.read(key);
+ res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
+ connectorRestClient.check(connector)
+ ? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
+ } catch (Exception e) {
+ LOG.warn("Error checking connection for {}", key, e);
+ res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.FAILURE, key);
+ }
+
+ synchronized (runningConnCheck) {
+ connectors.put(key, res);
+ runningConnCheck.remove(key);
+ }
+ } finally {
+ ThreadContext.detach();
+ }
+ }
+ }
+
+ class ResCheck implements Runnable {
+
+ private final String key;
+
+ private final Application application;
+
+ private final Session session;
+
+ ResCheck(final String key) {
+ this.key = key;
+ this.application = Application.get();
+ this.session = Session.exists() ? Session.get() : null;
+ }
+
+ @Override
+ public void run() {
+ try {
+ ThreadContext.setApplication(application);
+ ThreadContext.setSession(session);
+
+ String res;
+ try {
+ final ResourceTO resource = resourceRestClient.read(key);
+ res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
+ connectorRestClient.check(resource)
+ ? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
+ } catch (Exception e) {
+ LOG.warn("Error checking connection for {}", key, e);
+ res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.FAILURE, key);
+ }
+
+ synchronized (runningResCheck) {
+ resources.put(key, res);
+ runningResCheck.remove(key);
+ }
+ } finally {
+ ThreadContext.detach();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/client/console/src/main/java/org/apache/syncope/client/console/topology/WebSocketBehavior.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/WebSocketBehavior.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/WebSocketBehavior.java
deleted file mode 100644
index 8e3267d..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/topology/WebSocketBehavior.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.console.topology;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.apache.syncope.client.console.rest.ConnectorRestClient;
-import org.apache.syncope.client.console.rest.ResourceRestClient;
-import org.apache.syncope.common.lib.to.ConnInstanceTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.wicket.Application;
-import org.apache.wicket.Session;
-import org.apache.wicket.ThreadContext;
-import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
-import org.apache.wicket.protocol.ws.api.message.TextMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WebSocketBehavior extends org.apache.wicket.protocol.ws.api.WebSocketBehavior {
-
- protected static final Logger LOG = LoggerFactory.getLogger(WebSocketBehavior.class);
-
- private static final long serialVersionUID = -1653665542635275551L;
-
- private final Map<String, String> resources = new HashMap<>();
-
- private final Set<String> runningResCheck = new HashSet<>();
-
- private final Map<Long, String> connectors = new HashMap<>();
-
- private final Set<Long> runningConnCheck = new HashSet<>();
-
- private final ConnectorRestClient connectorRestClient = new ConnectorRestClient();
-
- private final ResourceRestClient resourceRestClient = new ResourceRestClient();
-
- @Override
- protected void onMessage(final WebSocketRequestHandler handler, final TextMessage message) {
- try {
- final ObjectMapper mapper = new ObjectMapper();
- final JsonNode obj = mapper.readTree(message.getText());
-
- final ExecutorService executorService = Executors.newFixedThreadPool(1);
-
- switch (Topology.SupportedOperation.valueOf(obj.get("kind").asText())) {
- case CHECK_CONNECTOR:
- final Long ckey = obj.get("target").asLong();
-
- if (connectors.containsKey(ckey)) {
- handler.push(connectors.get(ckey));
- } else {
- handler.push(String.format(
- "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, ckey));
- }
-
- synchronized (runningConnCheck) {
- if (runningConnCheck.contains(ckey)) {
- LOG.debug("Running connection check for connector {}", ckey);
- } else {
- runningConnCheck.add(ckey);
- }
- }
-
- executorService.execute(new ConnCheck(ckey));
-
- break;
- case CHECK_RESOURCE:
- final String rkey = obj.get("target").asText();
-
- if (resources.containsKey(rkey)) {
- handler.push(resources.get(rkey));
- } else {
- handler.push(String.format(
- "{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.UNKNOWN, rkey));
- }
-
- synchronized (runningResCheck) {
- if (runningResCheck.contains(rkey)) {
- LOG.debug("Running connection check for resource {}", rkey);
- } else {
- runningResCheck.add(rkey);
- }
- }
-
- executorService.execute(new ResCheck(rkey));
-
- break;
- case ADD_ENDPOINT:
- handler.appendJavaScript(String.format("addEndpoint('%s', '%s', '%s');",
- obj.get("source").asText(),
- obj.get("target").asText(),
- obj.get("scope").asText()));
- break;
- default:
- }
-
- executorService.shutdown();
-
- } catch (IOException e) {
- LOG.error("Eror managing websocket message", e);
- }
- }
-
- class ConnCheck implements Runnable {
-
- private final Long key;
-
- private final Application application;
-
- private final Session session;
-
- ConnCheck(final Long key) {
- this.key = key;
- this.application = Application.get();
- this.session = Session.exists() ? Session.get() : null;
- }
-
- @Override
- public void run() {
- try {
- ThreadContext.setApplication(application);
- ThreadContext.setSession(session);
-
- String res;
- try {
- final ConnInstanceTO connector = connectorRestClient.read(key);
- res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
- connectorRestClient.check(connector)
- ? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
- } catch (Exception e) {
- LOG.warn("Error checking connection for {}", key, e);
- res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.FAILURE, key);
- }
-
- synchronized (runningConnCheck) {
- connectors.put(key, res);
- runningConnCheck.remove(key);
- }
- } finally {
- ThreadContext.detach();
- }
- }
- }
-
- class ResCheck implements Runnable {
-
- private final String key;
-
- private final Application application;
-
- private final Session session;
-
- ResCheck(final String key) {
- this.key = key;
- this.application = Application.get();
- this.session = Session.exists() ? Session.get() : null;
- }
-
- @Override
- public void run() {
- try {
- ThreadContext.setApplication(application);
- ThreadContext.setSession(session);
-
- String res;
- try {
- final ResourceTO resource = resourceRestClient.read(key);
- res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
- connectorRestClient.check(resource)
- ? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
- } catch (Exception e) {
- LOG.warn("Error checking connection for {}", key, e);
- res = String.format("{ \"status\": \"%s\", \"target\": \"%s\"}", TopologyNode.Status.FAILURE, key);
- }
-
- synchronized (runningResCheck) {
- resources.put(key, res);
- runningResCheck.remove(key);
- }
- } finally {
- ThreadContext.detach();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
index eeb4e64..202461d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/LoadWidget.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.syncope.common.lib.info.SystemInfo;
+import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
public class LoadWidget extends AbstractWidget {
@@ -34,12 +35,16 @@ public class LoadWidget extends AbstractWidget {
public LoadWidget(final String id, final SystemInfo systeminfo) {
super(id);
+ add(new Label("hostname", systeminfo.getHostname()));
+ add(new Label("os", systeminfo.getOs()));
+ add(new Label("jvm", systeminfo.getJvm()));
+
List<String> labels = new ArrayList<>();
List<Double> cpuValues = new ArrayList<>();
List<Long> memValues = new ArrayList<>();
- for (SystemInfo.PlatformLoad instant : systeminfo.getLoad()) {
+ for (SystemInfo.LoadInstant instant : systeminfo.getLoad()) {
labels.add(DateFormatUtils.ISO_DATETIME_FORMAT.format(systeminfo.getStartTime() + instant.getUptime()));
cpuValues.add(instant.getSystemLoadAverage() * 1000);
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
index 45c5d29..82aff57 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/widgets/LoadWidget.html
@@ -23,6 +23,16 @@ under the License.
<div class="box-header with-border">
<h3 class="box-title"><wicket:message key="systemLoad"/></h3>
<div class="box-tools pull-right">
+ <div class="btn-group">
+ <button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown">
+ <i class="fa fa-info"></i>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="#"><span wicket:id="hostname"/></a></li>
+ <li><a href="#"><span wicket:id="os"/></a></li>
+ <li><a href="#"><span wicket:id="jvm"/></a></li>
+ </ul>
+ </div>
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java b/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java
index 2f25320..d660451 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java
@@ -32,6 +32,8 @@ public class SystemInfo extends AbstractBaseBean {
private static final long serialVersionUID = -352727968865892499L;
+ private String hostname;
+
private String os;
private String jvm;
@@ -40,7 +42,15 @@ public class SystemInfo extends AbstractBaseBean {
private long startTime;
- private final CircularFifoQueue<PlatformLoad> load = new CircularFifoQueue<>(10);
+ private final CircularFifoQueue<LoadInstant> load = new CircularFifoQueue<>(10);
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(final String hostname) {
+ this.hostname = hostname;
+ }
public String getOs() {
return os;
@@ -77,13 +87,13 @@ public class SystemInfo extends AbstractBaseBean {
@XmlElementWrapper(name = "load")
@XmlElement(name = "instant")
@JsonProperty("load")
- public CircularFifoQueue<PlatformLoad> getLoad() {
+ public CircularFifoQueue<LoadInstant> getLoad() {
return load;
}
- @XmlRootElement(name = "platformLoad")
+ @XmlRootElement(name = "loadInstant")
@XmlType
- public static class PlatformLoad extends AbstractBaseBean {
+ public static class LoadInstant extends AbstractBaseBean {
private static final long serialVersionUID = 1700788373758716478L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
index ad2f3b5..f15167d 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java
@@ -23,7 +23,9 @@ import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import org.apache.syncope.core.misc.EntitlementsHolder;
import java.lang.reflect.Method;
+import java.net.InetAddress;
import java.net.URI;
+import java.net.UnknownHostException;
import java.util.Iterator;
import java.util.Map;
import javax.annotation.Resource;
@@ -59,7 +61,7 @@ import org.springframework.transaction.annotation.Transactional;
@Component
public class SyncopeLogic extends AbstractLogic<AbstractBaseBean> {
- private static final int MB = 1024 * 1024;
+ private static final Object MONITOR = new Object();
private static PlatformInfo PLATFORM_INFO;
@@ -130,7 +132,7 @@ public class SyncopeLogic extends AbstractLogic<AbstractBaseBean> {
@PreAuthorize("isAuthenticated()")
public PlatformInfo platform() {
- synchronized (this) {
+ synchronized (MONITOR) {
if (PLATFORM_INFO == null) {
PLATFORM_INFO = new PlatformInfo();
PLATFORM_INFO.setVersion(version);
@@ -180,38 +182,42 @@ public class SyncopeLogic extends AbstractLogic<AbstractBaseBean> {
return PLATFORM_INFO;
}
- @PreAuthorize("isAuthenticated()")
- public SystemInfo system() {
- synchronized (this) {
+ private void initSystemInfo() {
+ if (SYSTEM_INFO == null) {
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
- if (SYSTEM_INFO == null) {
- SYSTEM_INFO = new SystemInfo();
- SYSTEM_INFO.setOs(operatingSystemMXBean.getName()
- + " " + operatingSystemMXBean.getVersion()
- + " " + operatingSystemMXBean.getArch());
- SYSTEM_INFO.setAvailableProcessors(operatingSystemMXBean.getAvailableProcessors());
- SYSTEM_INFO.setJvm(
- runtimeMXBean.getVmName()
- + " " + System.getProperty("java.version")
- + " " + runtimeMXBean.getVmVendor());
- SYSTEM_INFO.setStartTime(runtimeMXBean.getStartTime());
+ SYSTEM_INFO = new SystemInfo();
+ try {
+ SYSTEM_INFO.setHostname(InetAddress.getLocalHost().getHostName());
+ } catch (UnknownHostException e) {
+ LOG.error("Could not get host name", e);
}
- SystemInfo.PlatformLoad instant = new SystemInfo.PlatformLoad();
-
- instant.setSystemLoadAverage(operatingSystemMXBean.getSystemLoadAverage());
-
- instant.setUptime(runtimeMXBean.getUptime());
-
- Runtime runtime = Runtime.getRuntime();
- instant.setTotalMemory(runtime.totalMemory() / MB);
- instant.setMaxMemory(runtime.maxMemory() / MB);
- instant.setFreeMemory(runtime.freeMemory() / MB);
+ SYSTEM_INFO.setOs(operatingSystemMXBean.getName()
+ + " " + operatingSystemMXBean.getVersion()
+ + " " + operatingSystemMXBean.getArch());
+ SYSTEM_INFO.setAvailableProcessors(operatingSystemMXBean.getAvailableProcessors());
+ SYSTEM_INFO.setJvm(
+ runtimeMXBean.getVmName()
+ + " " + System.getProperty("java.version")
+ + " " + runtimeMXBean.getVmVendor());
+ SYSTEM_INFO.setStartTime(runtimeMXBean.getStartTime());
+ }
+ }
+ public void addLoadInstant(final SystemInfo.LoadInstant instant) {
+ synchronized (MONITOR) {
+ initSystemInfo();
SYSTEM_INFO.getLoad().add(instant);
}
+ }
+
+ @PreAuthorize("isAuthenticated()")
+ public SystemInfo system() {
+ synchronized (MONITOR) {
+ initSystemInfo();
+ }
return SYSTEM_INFO;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/core/logic/src/main/java/org/apache/syncope/core/logic/SystemLoadReporterJob.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SystemLoadReporterJob.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SystemLoadReporterJob.java
new file mode 100644
index 0000000..75e7f71
--- /dev/null
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SystemLoadReporterJob.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.logic;
+
+import java.lang.management.ManagementFactory;
+import org.apache.syncope.common.lib.info.SystemInfo;
+import org.quartz.DisallowConcurrentExecution;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Reports about system load.
+ */
+@Component
+@DisallowConcurrentExecution
+public class SystemLoadReporterJob implements Job {
+
+ private static final Integer MB = 1024 * 1024;
+
+ @Autowired
+ private SyncopeLogic logic;
+
+ @Override
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+ SystemInfo.LoadInstant instant = new SystemInfo.LoadInstant();
+
+ instant.setSystemLoadAverage(ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage());
+
+ instant.setUptime(ManagementFactory.getRuntimeMXBean().getUptime());
+
+ Runtime runtime = Runtime.getRuntime();
+ instant.setTotalMemory(runtime.totalMemory() / MB);
+ instant.setMaxMemory(runtime.maxMemory() / MB);
+ instant.setFreeMemory(runtime.freeMemory() / MB);
+
+ logic.addLoadInstant(instant);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/3f0f2562/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java b/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java
index dbcdd3f..29bdba7 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.core.logic.SystemLoadReporterJob;
import org.apache.syncope.core.persistence.api.dao.ConfDAO;
import org.apache.syncope.core.persistence.api.dao.NotFoundException;
import org.apache.syncope.core.persistence.api.dao.ReportDAO;
@@ -214,12 +215,6 @@ public class JobInstanceLoaderImpl implements JobInstanceLoader, SyncopeLoader {
registerJob(JobNamer.getJobName(report), job, report.getCronExpression(), startAt, jobMap);
}
- private void registerNotificationJob(final String cronExpression) throws SchedulerException, ParseException {
- NotificationJob job = createSpringBean(NotificationJob.class);
-
- registerJob("taskNotificationJob", job, cronExpression, null, Collections.<String, Object>emptyMap());
- }
-
private void unregisterJob(final String jobName) {
try {
scheduler.getScheduler().unscheduleJob(new TriggerKey(jobName, Scheduler.DEFAULT_GROUP));
@@ -304,16 +299,37 @@ public class JobInstanceLoaderImpl implements JobInstanceLoader, SyncopeLoader {
// 3. NotificationJob
if (StringUtils.isBlank(notificationConf.getLeft())) {
- LOG.debug("Empty value provided for NotificationJob's cron, not registering anything on Quartz");
+ LOG.debug("Empty value provided for {}'s cron, not registering anything on Quartz",
+ NotificationJob.class.getSimpleName());
} else {
- LOG.debug("NotificationJob's cron expression: {} - registering Quartz job and trigger",
- notificationConf.getLeft());
+ LOG.debug("{}'s cron expression: {} - registering Quartz job and trigger",
+ NotificationJob.class.getSimpleName(), notificationConf.getLeft());
try {
- registerNotificationJob(notificationConf.getLeft());
+ NotificationJob job = createSpringBean(NotificationJob.class);
+ registerJob(
+ "taskNotificationJob",
+ job,
+ notificationConf.getLeft(),
+ null,
+ Collections.<String, Object>emptyMap());
} catch (Exception e) {
- LOG.error("While loading NotificationJob instance", e);
+ LOG.error("While loading {} instance", NotificationJob.class.getSimpleName(), e);
}
}
+
+ // 4. SystemLoadReporterJob (fixed schedule, every minute)
+ LOG.debug("Registering {}", SystemLoadReporterJob.class);
+ try {
+ SystemLoadReporterJob job = createSpringBean(SystemLoadReporterJob.class);
+ registerJob(
+ "taskSystemLoadReporterJob",
+ job,
+ "0 * * * * ?",
+ null,
+ Collections.<String, Object>emptyMap());
+ } catch (Exception e) {
+ LOG.error("While loading {} instance", SystemLoadReporterJob.class.getSimpleName(), e);
+ }
}
}