Skip to content

Commit

Permalink
util/src/main/java/com/ning/arecibo/util/timeline/TimelineChunk.java:
Browse files Browse the repository at this point in the history
    Eliminate base class CachedObject, and change objectId to chunkId.

util/src/main/java/com/ning/arecibo/util/timeline/CachedObject.java:
util/src/main/java/com/ning/arecibo/util/timeline/LRUObjectCache.java:
util/src/main/java/com/ning/arecibo/util/timeline/TimelineCacheManager.java:

    Delete these now-unreferenced units.

collector/src/main/java/com/ning/arecibo/collector/persistent/TimelineAggregator.java:
util/src/main/java/com/ning/arecibo/util/timeline/TimelineChunkBinder.java:

    Use TimelineChunk.getChunkId() rather than getObjectId().

    Change the type of hostId and smapleKindId from Integer to int.

util/src/test/java/com/ning/arecibo/util/timeline/TestTimelineChunkToJson.java:

    Increment the number of keys expected by 1, because we now get
    chunkId.

util/src/main/java/com/ning/arecibo/util/timeline/TimelineDAO.java:
collector/src/test/java/com/ning/arecibo/collector/MockTimelineDAO.java:
util/src/main/java/com/ning/arecibo/util/timeline/CachingTimelineDAO.java:
util/src/main/java/com/ning/arecibo/util/timeline/DefaultTimelineDAO.java:

    Change the return types of getOrAddHostId(),
    getOrAddEventCategory(), and getOrAddSampleKindId() to be int
    rather than Integer.
  • Loading branch information
dstryker committed Apr 30, 2012
1 parent 24bad11 commit 43f5067
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void aggregateHostSampleChunks(final List<TimelineChunk> timelineChunks,
timeParts.add(timelineChunk.getTimes());
sampleParts.add(timelineChunk.getSamples());
sampleCount += timelineChunk.getSampleCount();
timelineChunkIds.add(timelineChunk.getObjectId());
timelineChunkIds.add(timelineChunk.getChunkId());
}
final byte[] combinedTimeBytes = TimelineCoder.combineTimelines(timeParts, sampleCount);
final byte[] combinedSampleBytes = SampleCoder.combineSampleBytes(sampleParts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public BiMap<Integer, String> getHosts()
}

@Override
public Integer getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
public int getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
{
synchronized (hosts) {
final Integer hostId = getHostId(host);
Expand Down Expand Up @@ -101,7 +101,7 @@ public String getEventCategory(Integer eventCategoryId) throws UnableToObtainCon
}

@Override
public Integer getOrAddEventCategory( String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
public int getOrAddEventCategory( String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
synchronized (eventCategories) {
Integer eventCategoryId = getEventCategoryId(eventCategory);
if (eventCategoryId == null) {
Expand Down Expand Up @@ -143,7 +143,7 @@ public BiMap<Integer, CategoryIdAndSampleKind> getSampleKinds()
}

@Override
public Integer getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
public int getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
{
synchronized (sampleKinds) {
Integer sampleKindId = getSampleKindId(eventCategoryId, sampleKind);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public BiMap<Integer, String> getHosts() throws UnableToObtainConnectionExceptio
}

@Override
public synchronized Integer getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
public synchronized int getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
{
Integer hostId = hostsCache.inverse().get(host);
if (hostId == null) {
Expand Down Expand Up @@ -112,7 +112,7 @@ public BiMap<Integer, String> getEventCategories() throws UnableToObtainConnecti
}

@Override
public Integer getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
public int getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
Integer eventCategoryId = eventCategoriesCache.inverse().get(eventCategory);
if (eventCategoryId == null) {
eventCategoryId = delegate.getOrAddEventCategory(eventCategory);
Expand Down Expand Up @@ -140,7 +140,7 @@ public BiMap<Integer, CategoryIdAndSampleKind> getSampleKinds() throws UnableToO
}

@Override
public synchronized Integer getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
public synchronized int getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
{
final CategoryIdAndSampleKind categoryIdAndSampleKind = new CategoryIdAndSampleKind(eventCategoryId, sampleKind);
Integer sampleKindId = sampleKindsCache.inverse().get(categoryIdAndSampleKind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public BiMap<Integer, String> getHosts() throws UnableToObtainConnectionExceptio
}

@Override
public synchronized Integer getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
public synchronized int getOrAddHost(final String host) throws UnableToObtainConnectionException, CallbackFailedException
{
delegate.begin();
delegate.addHost(host);
Expand Down Expand Up @@ -108,7 +108,7 @@ public BiMap<Integer, String> getEventCategories() throws UnableToObtainConnecti
}

@Override
public synchronized Integer getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
public synchronized int getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException {
delegate.begin();
delegate.addEventCategory(eventCategory);
final Integer eventCategoryId = delegate.getEventCategoryId(eventCategory);
Expand Down Expand Up @@ -141,7 +141,7 @@ public BiMap<Integer, CategoryIdAndSampleKind> getSampleKinds() throws UnableToO
}

@Override
public synchronized Integer getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
public synchronized int getOrAddSampleKind(final Integer hostId, final Integer eventCategoryId, final String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException
{
delegate.begin();
delegate.addSampleKind(eventCategoryId, sampleKind);
Expand Down
127 changes: 0 additions & 127 deletions util/src/main/java/com/ning/arecibo/util/timeline/LRUObjectCache.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@
* for a single host and single sample kind. The samples are held in a byte
* array.
*/
public class TimelineChunk extends CachedObject
public class TimelineChunk
{
private static final Logger log = Logger.getCallersLoggerViaExpensiveMagic();
private static final ObjectMapper objectMapper = new ObjectMapper();

@JsonProperty
@JsonView(TimelineChunksViews.Base.class)
private final Integer hostId;
private final long chunkId;
@JsonProperty
@JsonView(TimelineChunksViews.Base.class)
private final Integer sampleKindId;
private final int hostId;
@JsonProperty
@JsonView(TimelineChunksViews.Base.class)
private final int sampleKindId;
@JsonProperty
@JsonView(TimelineChunksViews.Compact.class)
private final DateTime startTime;
Expand Down Expand Up @@ -72,7 +75,7 @@ public class TimelineChunk extends CachedObject

public TimelineChunk(final long chunkId, final int hostId, final int sampleKindId, final DateTime startTime, final DateTime endTime, final byte[] times, final byte[] samples, final int sampleCount)
{
super(chunkId);
this.chunkId = chunkId;
this.hostId = hostId;
this.sampleKindId = sampleKindId;
this.startTime = startTime;
Expand All @@ -88,7 +91,7 @@ public TimelineChunk(final long chunkId, final int hostId, final int sampleKindI
public TimelineChunk(final long chunkId, final int hostId, final int sampleKindId, final DateTime startTime, final DateTime endTime,
final byte[] times, final byte[] samples, final int sampleCount, final int aggregationLevel, final boolean notValid, final boolean dontAggregate)
{
super(chunkId);
this.chunkId = chunkId;
this.hostId = hostId;
this.sampleKindId = sampleKindId;
this.startTime = startTime;
Expand All @@ -103,7 +106,7 @@ public TimelineChunk(final long chunkId, final int hostId, final int sampleKindI

public TimelineChunk(final long chunkId, final TimelineChunk other)
{
super(chunkId);
this.chunkId = chunkId;
this.hostId = other.hostId;
this.sampleKindId = other.sampleKindId;
this.startTime = other.startTime;
Expand Down Expand Up @@ -186,7 +189,7 @@ public String toString()

public long getChunkId()
{
return getObjectId();
return chunkId;
}

public int getHostId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void bind(final SQLStatement query, final TimelineChunkBinder binder, fin
.bind("notValid", timelineChunk.getNotValid() ? 1 : 0)
.bind("dontAggregate", timelineChunk.getDontAggregate() ? 1 : 0);
final byte[] timesAndSamples = TimesAndSamplesCoder.combineTimesAndSamples(timelineChunk.getTimes(), timelineChunk.getSamples());
if (timelineChunk.getObjectId() == 0) {
if (timelineChunk.getChunkId() == 0) {
query.bindNull("chunkId", Types.BIGINT);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface TimelineDAO

BiMap<Integer, String> getHosts() throws UnableToObtainConnectionException, CallbackFailedException;

Integer getOrAddHost(String host) throws UnableToObtainConnectionException, CallbackFailedException;
int getOrAddHost(String host) throws UnableToObtainConnectionException, CallbackFailedException;

// Event categories table

Expand All @@ -46,7 +46,7 @@ public interface TimelineDAO

BiMap<Integer, String> getEventCategories() throws UnableToObtainConnectionException, CallbackFailedException;

Integer getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException;
int getOrAddEventCategory(String eventCategory) throws UnableToObtainConnectionException, CallbackFailedException;

// Sample kinds table

Expand All @@ -56,7 +56,7 @@ public interface TimelineDAO

BiMap<Integer, CategoryIdAndSampleKind> getSampleKinds() throws UnableToObtainConnectionException, CallbackFailedException;

Integer getOrAddSampleKind(Integer hostId, Integer eventCategoryId, String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException;
int getOrAddSampleKind(Integer hostId, Integer eventCategoryId, String sampleKind) throws UnableToObtainConnectionException, CallbackFailedException;

Iterable<Integer> getSampleKindIdsByHostId(Integer hostId) throws UnableToObtainConnectionException, CallbackFailedException;

Expand Down
Loading

0 comments on commit 43f5067

Please sign in to comment.