Skip to content

Commit

Permalink
Codeine 255 (#256)
Browse files Browse the repository at this point in the history
* codeine-253 disable connection pool on large deployment

* codeine-255 UI should use uniqe not on alias but on host:uqnie filed - also changed default node interval from 29 seconds to 60 and exposed it via configuration

* codeine-255 UI should use uniqe not on alias but on host:uqnie filed - also changed default node interval from 29 seconds to 60 and exposed it via configuration

* codeine-255 UI should use uniqe not on alias but on host:uqnie filed - also changed default node interval from 29 seconds to 60 and exposed it via configuration

* codeine-255 UI should use uniqe not on alias but on host:uqnie filed - also changed default node interval from 29 seconds to 60 and exposed it via configuration
  • Loading branch information
ezraroi authored and lchayoun committed Jun 27, 2019
1 parent edfffb7 commit 03a6b24
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@
</div>
</div>
</accordion-heading>
<div class="row" ng-repeat="node in versionItem.visibleNodes track by node.immutable.alias | orderBy:'alias'">
<div class="row"
ng-repeat="node in versionItem.visibleNodes track by node.immutable.name | orderBy:'alias'">
<div ng-class="{'col-md-3': maxNodeAliasLength <= maxNodeAliasLengthForSmallCol, 'col-md-5': maxNodeAliasLength > maxNodeAliasLengthForSmallCol}" class="fade_me" tooltip="{{::((node.immutable.alias.length > (maxNodeAliasLengthForSmallCol-5) && node.immutable.alias.length <= maxNodeAliasLengthForSmallCol) || node.immutable.alias.length > 40 ) ? node.immutable.alias : ''}}" tooltip-placement="right" tooltip-popup-delay="500">
<form class="form-inline" role="form">
<div class="checkbox">
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<properties>
<prometheus_client_version>0.3.0</prometheus_client_version>
<drop_wizard_version>3.2.6</drop_wizard_version>
<jetty_version>9.4.11.v20180605</jetty_version>
<jetty_version>9.4.17.v20190418</jetty_version>
</properties>
<build>
<sourceDirectory>src/external/mysql_lib</sourceDirectory>
Expand Down Expand Up @@ -123,7 +123,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<version>2.22.2</version>
<configuration>
<includes>
<include>integration_tests/**/*Test.java</include>
Expand Down
5 changes: 5 additions & 0 deletions src/common/codeine/jsons/global/GlobalConfigurationJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class GlobalConfigurationJson {
private boolean prometheus_enabled = true;
private Integer connectivity_check_timeout_ms = 3000;
private boolean consul_registration;
private Integer node_interval_seconds = 60;

public GlobalConfigurationJson() {
}
Expand Down Expand Up @@ -115,4 +116,8 @@ public Integer connectivity_check_timeout_ms() {
return connectivity_check_timeout_ms;
}

public Integer node_interval_seconds() {
return node_interval_seconds;
}

}
51 changes: 19 additions & 32 deletions src/peer/codeine/nodes/NodesRunner.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package codeine.nodes;

import codeine.PeerStatusChangedUpdater;
import codeine.SnoozeKeeper;
import codeine.api.NodeInfo;
import codeine.collectors.CollectorsRunner;
import codeine.collectors.CollectorsRunnerFactory;
import codeine.configuration.IConfigurationManager;
import codeine.configuration.PathHelper;
import codeine.executer.PeriodicExecuter;
import codeine.executer.Task;
import codeine.jsons.global.GlobalConfigurationJsonStore;
import codeine.jsons.global.GlobalConfigurationJson;
import codeine.jsons.nodes.NodesManager;
import codeine.jsons.peer_status.PeerStatus;
import codeine.jsons.project.ProjectJson;
import codeine.mail.MailSender;
import codeine.mail.NotificationDeliverToDatabase;
import codeine.utils.network.InetUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
Expand All @@ -32,8 +27,10 @@ public class NodesRunner implements Task {

private static final Logger log = Logger.getLogger(NodesRunner.class);

private static final long NODE_MONITOR_INTERVAL = TimeUnit.SECONDS.toMillis(29);
public static final long NODE_RUNNER_INTERVAL = TimeUnit.HOURS.toMillis(1);
private long nodeMonitorInterval = TimeUnit.SECONDS.toMillis(60);

@Inject
private GlobalConfigurationJson globalConfigurationJson;

@Inject
private IConfigurationManager configurationManager;
Expand All @@ -51,10 +48,11 @@ public class NodesRunner implements Task {

@Override
public synchronized void run() {
nodeMonitorInterval = TimeUnit.SECONDS.toMillis(globalConfigurationJson.node_interval_seconds());
InetAddress localHost = InetUtils.getLocalHost();
log.info("NodeRunner is starting on host " + localHost.getHostName() + " " + localHost
.getCanonicalHostName());
log.info("NodeRunner is starting " + this + " with executers " + executers);
log.info("NodeRunner is starting on host " + localHost.getHostName() + " " + localHost.getCanonicalHostName());
log.info("NodeRunner is starting " + this + " with executers " + executers + " interval is "
+ nodeMonitorInterval);
Set<String> removedProjects = Sets.newHashSet(executers.keySet());
for (ProjectJson project : getProjects()) {
removedProjects.remove(project.name());
Expand Down Expand Up @@ -94,34 +92,29 @@ private void stop(PeriodicExecuter e) {

private boolean startStopExecutorsForProject(ProjectJson project) {
Map<NodeInfo, PeriodicExecuter> currentNodes = getCurrentNodes(project);
log.info(
"project: " + project.name() + " currentProjectExecutors: " + currentNodes.keySet());
log.info("project: " + project.name() + " currentProjectExecutors: " + currentNodes.keySet());
SelectedNodes selectedNodes;
try {
selectedNodes = new NodesSelector(currentNodes, getNodes(project)).selectStartStop();
} catch (Exception e) {
log.error(
"failed to select nodes for project " + project.name() + " will leave old nodes "
+ currentNodes, e);
log.error("failed to select nodes for project " + project.name() + " will leave old nodes " + currentNodes,
e);
return !currentNodes.isEmpty();
}
log.info("selectedNodes: " + selectedNodes);
stopNodes(project.name(), selectedNodes.nodesToStop());
Map<NodeInfo, PeriodicExecuter> newProjectExecutors = selectedNodes
.existingProjectExecutors();
Map<NodeInfo, PeriodicExecuter> newProjectExecutors = selectedNodes.existingProjectExecutors();
for (NodeInfo nodeJson : selectedNodes.nodesToStart()) {
log.info("start exec1 monitoring node " + nodeJson + " in project " + project.name());
try {
PeriodicExecuter e = startExecuter(project, nodeJson);
newProjectExecutors.put(nodeJson, e);
} catch (Exception e1) {
log.error("failed to start executor for node " + nodeJson + " in project " + project
.name(), e1);
log.error("failed to start executor for node " + nodeJson + " in project " + project.name(), e1);
}
}
executers.put(project.name(), newProjectExecutors);
log.info(
"project: " + project.name() + " newProjectExecutors: " + newProjectExecutors.keySet());
log.info("project: " + project.name() + " newProjectExecutors: " + newProjectExecutors.keySet());
return !executers.get(project.name()).isEmpty();
}

Expand All @@ -134,23 +127,17 @@ private void stopNodes(String project, Map<NodeInfo, PeriodicExecuter> map) {
}

private Map<NodeInfo, PeriodicExecuter> getCurrentNodes(ProjectJson project) {
Map<NodeInfo, PeriodicExecuter> currentNodes = executers.get(project.name());
if (null == currentNodes) {
currentNodes = Maps.newHashMap();
executers.put(project.name(), currentNodes);
}
return currentNodes;
return executers.computeIfAbsent(project.name(), k -> Maps.newHashMap());
}

private PeriodicExecuter startExecuter(ProjectJson project, NodeInfo nodeJson) {
log.info("Starting monitor thread for project " + project.name() + " node " + nodeJson);
Task task;
CollectorsRunner collectorsTask = collectorsRunnerFactory
.create(project.name(), nodeJson);
CollectorsRunner collectorsTask = collectorsRunnerFactory.create(project.name(), nodeJson);
collectorsTask.init();
task = collectorsTask;
PeriodicExecuter periodicExecuter = new PeriodicExecuter(NODE_MONITOR_INTERVAL,
task, "RunMonitors_" + project.name() + "_" + nodeJson.name());
PeriodicExecuter periodicExecuter = new PeriodicExecuter(nodeMonitorInterval, task,
"RunMonitors_" + project.name() + "_" + nodeJson.name());
log.info("starting 1executor " + periodicExecuter.name());
periodicExecuter.runInThread();
return periodicExecuter;
Expand Down

0 comments on commit 03a6b24

Please sign in to comment.