Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHQ6059 : Solution for problem : measurement handler is eating 90% of…
… the cpu
- Loading branch information
Irena Goverdovsky
committed
Oct 7, 2015
1 parent
aed1015
commit 7e974be
Showing
13 changed files
with
956 additions
and
630 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
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
38 changes: 38 additions & 0 deletions
38
...urement/src/main/java/org/hyperic/hq/measurement/agent/server/SchedulerOffsetManager.java
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.hyperic.hq.measurement.agent.server; | ||
|
||
import java.util.Random; | ||
|
||
import org.hyperic.hq.agent.server.AgentStorageProvider; | ||
import org.hyperic.util.TimeUtil; | ||
|
||
public class SchedulerOffsetManager { | ||
|
||
private static final String PROP_SCHEDULER_OFFSET_SEED = "agent.scheduler.offset.seed"; | ||
|
||
private long offsetSeed; | ||
|
||
public SchedulerOffsetManager(AgentStorageProvider storage) { | ||
offsetSeed = getSchedulerOffsetSeed(storage); | ||
} | ||
|
||
private long getSchedulerOffsetSeed(AgentStorageProvider storage) { | ||
String offsetSeedString = storage.getValue(PROP_SCHEDULER_OFFSET_SEED); | ||
long offsetSeed; | ||
if (offsetSeedString != null) { | ||
offsetSeed = Long.parseLong(offsetSeedString); | ||
} else { | ||
Random rand = new Random(); | ||
offsetSeed = Math.abs(rand.nextLong()); | ||
storage.setValue(PROP_SCHEDULER_OFFSET_SEED, Long.toString(offsetSeed)); | ||
} | ||
return offsetSeed; | ||
} | ||
|
||
public long getSchedluerOffsetForInterval(long interval) { | ||
long offset = offsetSeed % interval; | ||
// Round offset to the nearest minute | ||
offset -= (offset % TimeUtil.MILLIS_IN_MINUTE); | ||
return offset; | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
...er-measurement/src/main/java/org/hyperic/hq/measurement/agent/server/SendBatchResult.java
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2015 VMware, Inc. All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License version 3 as published by the Free | ||
* Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.hyperic.hq.measurement.agent.server; | ||
|
||
import org.apache.commons.lang.builder.ToStringBuilder; | ||
|
||
public class SendBatchResult { | ||
|
||
public enum StatusBatchResult { | ||
SUCCESS_ALL, ERROR_ALL, SUCCESS_BATCH, ERROR_BATCH | ||
} | ||
|
||
private long timeStamp = 0; // in milliseconds | ||
private StatusBatchResult status; | ||
|
||
public SendBatchResult(StatusBatchResult status, long timeStamp) { | ||
this.timeStamp = timeStamp; | ||
this.status = status; | ||
} | ||
|
||
public SendBatchResult(StatusBatchResult status) { | ||
this.status = status; | ||
} | ||
|
||
public long getTimeStamp() { | ||
return timeStamp; | ||
} | ||
|
||
public StatusBatchResult getStatus() { | ||
return status; | ||
} | ||
|
||
public boolean isDone() { | ||
return StatusBatchResult.ERROR_ALL.equals(status) | ||
|| StatusBatchResult.SUCCESS_ALL.equals(status); | ||
|
||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this).append("Status", status.toString()) | ||
.append("Timestamp", timeStamp).toString(); | ||
|
||
} | ||
|
||
} |
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.