-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some refactoring adding properties collection for webapps
- Loading branch information
Showing
7 changed files
with
247 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,25 +7,35 @@ | |
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.locks.Lock; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
public class HeartBeatModule implements TelemetryModule { | ||
|
||
private final HeartBeatProviderInterface heartBeatProviderInterface; | ||
|
||
private Lock lock = new ReentrantLock(); | ||
|
||
private boolean isEnabled = false; | ||
|
||
public HeartBeatModule(Map<String, String> properties) { | ||
|
||
heartBeatProviderInterface = new HeartBeatProvider(); | ||
|
||
if (properties != null) { | ||
for (Map.Entry<String, String> entry : properties.entrySet()) { | ||
switch (entry.getKey()) { | ||
case "HeartBeatInterval": | ||
try { | ||
setHeartBeatInterval(Long.valueOf(entry.getValue())); | ||
break; | ||
} catch (Exception e) { | ||
//add log | ||
} | ||
case "isHeartBeatEnabled": | ||
try { | ||
setHeartBeatEnabled(Boolean.parseBoolean(entry.getValue())); | ||
break; | ||
} | ||
catch (Exception e) { | ||
//log | ||
|
@@ -34,6 +44,7 @@ public HeartBeatModule(Map<String, String> properties) { | |
try { | ||
List<String> excludedHeartBeatPropertiesProviderList = parseStringToList(entry.getValue()); | ||
setExcludedHeartBeatPropertiesProvider(excludedHeartBeatPropertiesProviderList); | ||
break; | ||
} | ||
catch (Exception e) { | ||
//log | ||
|
@@ -42,15 +53,17 @@ public HeartBeatModule(Map<String, String> properties) { | |
try { | ||
List<String> excludedHeartBeatPropertiesList = parseStringToList(entry.getValue()); | ||
setExcludedHeartBeatProperties(excludedHeartBeatPropertiesList); | ||
break; | ||
} | ||
catch (Exception e) { | ||
//log | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
heartBeatProviderInterface = new HeartBeatProvider(); | ||
} | ||
|
||
public long getHeartBeatInterval() { | ||
|
@@ -88,7 +101,18 @@ public void setHeartBeatEnabled(boolean heartBeatEnabled) { | |
|
||
@Override | ||
public void initialize(TelemetryConfiguration configuration) { | ||
InternalLogger.INSTANCE.info("heartbeat is enabled"); | ||
lock.lock(); | ||
try { | ||
if (!isEnabled) { | ||
this.heartBeatProviderInterface.initialize(configuration); | ||
InternalLogger.INSTANCE.info("heartbeat is enabled"); | ||
} | ||
isEnabled = true; | ||
} | ||
finally{ | ||
lock.lock(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dhaval24
Author
Contributor
|
||
} | ||
|
||
} | ||
|
||
private List<String> parseStringToList(String value) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
@dhaval24 I think here should be
unlock()