Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into SliceFilter
- Loading branch information
Showing
17 changed files
with
325 additions
and
8 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
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
46 changes: 46 additions & 0 deletions
46
core/src/main/java/me/prettyprint/cassandra/connection/MetricsOpTimer.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,46 @@ | |||
package me.prettyprint.cassandra.connection; | |||
|
|||
import java.util.concurrent.TimeUnit; | |||
|
|||
import com.yammer.metrics.core.MetricName; | |||
import com.yammer.metrics.core.MetricsRegistry; | |||
import com.yammer.metrics.core.Timer; | |||
import com.yammer.metrics.core.TimerContext; | |||
|
|||
public class MetricsOpTimer implements HOpTimer { | |||
|
|||
private static final String TIMER_TYPE = "hector"; | |||
private final MetricsRegistry metricsRegistry; | |||
private final TimeUnit durationUnit; | |||
private final TimeUnit rateUnit; | |||
private final String clusterName; | |||
|
|||
public MetricsOpTimer(final MetricsRegistry metricsRegistry, final String clusterName, | |||
final TimeUnit durationUnit, final TimeUnit rateUnit) { | |||
this.metricsRegistry = metricsRegistry; | |||
this.clusterName = clusterName; | |||
this.durationUnit = durationUnit; | |||
this.rateUnit = rateUnit; | |||
} | |||
|
|||
public MetricsOpTimer(final String clusterName) { | |||
this.metricsRegistry = new MetricsRegistry(); | |||
this.clusterName = clusterName; | |||
this.durationUnit = TimeUnit.NANOSECONDS; | |||
this.rateUnit = TimeUnit.SECONDS; | |||
} | |||
|
|||
@Override | |||
public Object start(final String tagName) { | |||
final Timer timer = metricsRegistry.newTimer(new MetricName(clusterName, TIMER_TYPE, tagName), | |||
durationUnit, rateUnit); | |||
return timer.time(); | |||
} | |||
|
|||
@Override | |||
public void stop(final Object token, final String tagName, final boolean success) { | |||
final TimerContext timerContext = (TimerContext) token; | |||
timerContext.stop(); | |||
} | |||
|
|||
} |
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
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
70 changes: 70 additions & 0 deletions
70
core/src/main/java/me/prettyprint/cassandra/service/template/ColumnFamilyResultIterator.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,70 @@ | |||
/** | |||
* This class will instill 'normal' iterator behavior to a ColumnFamilyResult. | |||
* Simply instantiate this class while passing your ColumnFamilyResult as a | |||
* constructor argument. | |||
* | |||
* Ex. | |||
* | |||
* ColumnFamilyResultIterator myResultsInterator = | |||
* new ColumnFamilyResultIterator(someColumnFamilyResult); | |||
* | |||
* You can then use myResultsInterator with for loops or iterate with a while loop | |||
* just as with any standard java iterator. | |||
* | |||
*/ | |||
package me.prettyprint.cassandra.service.template; | |||
|
|||
import java.util.Iterator; | |||
|
|||
import me.prettyprint.cassandra.service.template.ColumnFamilyResult; | |||
|
|||
public class ColumnFamilyResultIterator implements Iterator<ColumnFamilyResult<?,?>> { | |||
private ColumnFamilyResult<?, ?> res; | |||
private boolean isStart = true; | |||
|
|||
public ColumnFamilyResultIterator(ColumnFamilyResult<?, ?> res) { | |||
this.res = res; | |||
} | |||
|
|||
public boolean hasNext() | |||
{ | |||
boolean retval = false; | |||
if (isStart) | |||
{ | |||
retval = res.hasResults(); | |||
} | |||
else | |||
{ | |||
retval = res.hasNext(); | |||
} | |||
return retval; | |||
} | |||
|
|||
public ColumnFamilyResult<?, ?> getRes() | |||
{ | |||
return res; | |||
} | |||
|
|||
public void setRes(ColumnFamilyResult<?, ?> res) | |||
{ | |||
this.res = res; | |||
} | |||
|
|||
public ColumnFamilyResult<?, ?> next() | |||
{ | |||
if (isStart) | |||
{ | |||
isStart = false; | |||
return res; | |||
} | |||
else | |||
{ | |||
return (ColumnFamilyResult<?, ?>) res.next(); | |||
} | |||
} | |||
|
|||
public void remove() | |||
{ | |||
res.remove(); | |||
} | |||
} |
Oops, something went wrong.