Small format changes in script and monitor packages

Just three files - just adding {}s to if and for statements or making
them single line.
This commit is contained in:
Nik Everett 2016-04-13 22:00:04 -04:00
parent 0386d8ec84
commit 86a9365c53
3 changed files with 35 additions and 37 deletions

View File

@ -79,29 +79,34 @@ public class DeadlockAnalyzer {
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>(); Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) { for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>(); LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId()))) for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId()))) {
cycle.add(t); cycle.add(t);
}
if (!cycles.contains(cycle)) if (!cycles.contains(cycle)) {
cycles.add(cycle); cycles.add(cycle);
} }
}
return cycles; return cycles;
} }
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap, Set<LinkedHashSet<ThreadInfo>> cycles) { private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap,
Set<LinkedHashSet<ThreadInfo>> cycles) {
ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds()); ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds());
Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>(); Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>();
Set<Long> knownDeadlockedThreads = threadInfoMap.keySet(); Set<Long> knownDeadlockedThreads = threadInfoMap.keySet();
for (ThreadInfo threadInfo : allThreads) { for (ThreadInfo threadInfo : allThreads) {
Thread.State state = threadInfo.getThreadState(); Thread.State state = threadInfo.getThreadState();
if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) { if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) {
for (LinkedHashSet cycle : cycles) { for (LinkedHashSet<ThreadInfo> cycle : cycles) {
if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) { if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) {
LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>(); LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>();
for (ThreadInfo node = threadInfo; !chain.contains(node); node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId()))) ThreadInfo node = threadInfo;
while (!chain.contains(node)) {
chain.add(node); chain.add(node);
node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId()));
}
deadlockChain.add(chain); deadlockChain.add(chain);
} }
} }
@ -135,10 +140,12 @@ public class DeadlockAnalyzer {
for (int x = 0; x < members.length; x++) { for (int x = 0; x < members.length; x++) {
ThreadInfo ti = members[x]; ThreadInfo ti = members[x];
sb.append(ti.getThreadName()); sb.append(ti.getThreadName());
if (x < members.length) if (x < members.length) {
sb.append(" > "); sb.append(" > ");
if (x == members.length - 1) }
if (x == members.length - 1) {
sb.append(ti.getLockOwnerName()); sb.append(ti.getLockOwnerName());
}
builder.add(ti.getThreadId()); builder.add(ti.getThreadId());
} }
this.description = sb.toString(); this.description = sb.toString();

View File

@ -46,7 +46,6 @@ public class Script implements ToXContent, Streamable {
* using {@link StreamInput#readOptionalStreamable(Supplier)} * using {@link StreamInput#readOptionalStreamable(Supplier)}
*/ */
public static final Supplier<Script> SUPPLIER = new Supplier<Script>() { public static final Supplier<Script> SUPPLIER = new Supplier<Script>() {
@Override @Override
public Script get() { public Script get() {
return new Script(); return new Script();
@ -238,30 +237,26 @@ public class Script implements ToXContent, Streamable {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) return true;
return true; if (obj == null) return false;
if (obj == null) if (getClass() != obj.getClass()) return false;
return false;
if (getClass() != obj.getClass())
return false;
Script other = (Script) obj; Script other = (Script) obj;
if (lang == null) { if (lang == null) {
if (other.lang != null) if (other.lang != null) return false;
return false; } else {
} else if (!lang.equals(other.lang)) if (!lang.equals(other.lang)) return false;
return false; }
if (params == null) { if (params == null) {
if (other.params != null) if (other.params != null) return false;
return false; } else {
} else if (!params.equals(other.params)) if (!params.equals(other.params)) return false;
return false; }
if (script == null) { if (script == null) {
if (other.script != null) if (other.script != null) return false;
return false; } else {
} else if (!script.equals(other.script)) if (!script.equals(other.script)) return false;
return false; }
if (type != other.type) if (type != other.type) return false;
return false;
return true; return true;
} }

View File

@ -149,15 +149,11 @@ public class Template extends Script {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) return true;
return true; if (!super.equals(obj)) return false;
if (!super.equals(obj)) if (getClass() != obj.getClass()) return false;
return false;
if (getClass() != obj.getClass())
return false;
Template other = (Template) obj; Template other = (Template) obj;
if (contentType != other.contentType) if (contentType != other.contentType) return false;
return false;
return true; return true;
} }