Methods Summary |
---|
public void | addDeleted(java.lang.String entryId, java.lang.String feedId)Adds a deleted entry to the buffer.
this.writeLock.lock();
try {
Map<String, StorageEntryWrapper> tempMap = this.bufferMap
.get(feedId);
if (tempMap != null) {
tempMap.remove(entryId);
this.addLastModified(feedId, new Long(System
.currentTimeMillis()));
}
/*
* add to exclude from searches
*/
if (!this.excludeList.contains(entryId))
this.excludeList.add(entryId);
} finally {
this.writeLock.unlock();
}
|
public void | addEntry(StorageEntryWrapper wrapper)Adds a {@link StorageEntryWrapper} to the buffer. If a wrapper
representing the same entry are already in the buffer the wrapper will be
replaced.
This method does ignore already delted entries. This should before the
entry is added to the buffer.
this.writeLock.lock();
try {
if (LOG.isInfoEnabled())
LOG.info(" Buffering wrapper - " + wrapper.getOperation()
+ " ID: " + wrapper.getEntryId() + " FeedID: "
+ wrapper.getFeedId());
if (wrapper.getOperation().equals(StorageOperation.DELETE))
return;
String feedId = wrapper.getFeedId();
if (this.bufferMap.containsKey(feedId))
this.bufferMap.get(feedId).put(wrapper.getEntryId(), wrapper);
else {
Map<String, StorageEntryWrapper> newFeedMap = new HashMap<String, StorageEntryWrapper>(
20);
newFeedMap.put(wrapper.getEntryId(), wrapper);
this.bufferMap.put(feedId, newFeedMap);
}
addLastModified(wrapper.getFeedId(), wrapper.getTimestamp());
/*
* add to exclude from searches doc will be available via the buffer
* if the entry is not already in the buffer
*/
if (!this.excludeList.contains(wrapper.getEntryId()))
this.excludeList.add(wrapper.getEntryId());
} finally {
this.writeLock.unlock();
}
|
private void | addLastModified(java.lang.String feedId, java.lang.Long timestamp)
this.writeLock.lock();
try {
if (this.modifiyMap.containsKey(feedId))
this.modifiyMap.remove(feedId);
this.modifiyMap.put(feedId, timestamp);
} finally {
this.writeLock.unlock();
}
|
private void | clearBuffer()
this.bufferMap.clear();
this.excludeList.clear();
this.modifiyMap.clear();
|
public void | close()clears the buffer -
this.writeLock.lock();
try {
clearBuffer();
} finally {
this.writeLock.unlock();
}
|
public int | getBufferSize()
return this.bufferSize;
|
public StorageEntryWrapper | getEntry(java.lang.String entryId, java.lang.String feedId)Returns an entry for the given entry id in the feed context spezified by
the feed id;
this.readLock.lock();
try {
if (this.bufferMap.containsKey(feedId))
return this.bufferMap.get(feedId).get(entryId);
return null;
} finally {
this.readLock.unlock();
}
|
public java.lang.String[] | getExculdList()The buffer contains updated and delete entries. These entries are already
available in the lucene index but should not be found during search.
This list contains all entries should not be found by the index searcher.
This method creates a copy of the current list to prevent concurrent
modification exceptions while iteration over the collection.
this.readLock.lock();
try {
return this.excludeList
.toArray(new String[this.excludeList.size()]);
} finally {
this.readLock.unlock();
}
|
protected java.lang.Long | getFeedLastModified(java.lang.String feedId)the timestamp of the last modification for the given feed id
this.readLock.lock();
try {
return this.modifiyMap.get(feedId);
} finally {
this.readLock.unlock();
}
|
protected java.util.Set | getLastModified()
return this.modifiyMap.entrySet();
|
public java.util.List | getSortedEntries(java.lang.String feedId)Returns all entries for the given feed id sorted by the update timestamp
desc.
this.readLock.lock();
try {
if (!this.bufferMap.containsKey(feedId))
return null;
Map<String, StorageEntryWrapper> tempMap = this.bufferMap
.get(feedId);
if (tempMap == null)
return null;
Collection<StorageEntryWrapper> col = tempMap.values();
List<StorageEntryWrapper> returnList = new ArrayList<StorageEntryWrapper>(
col);
Collections.sort(returnList);
return returnList;
} finally {
this.readLock.unlock();
}
|