use of org.apache.jackrabbit.core.journal.Journal in project jackrabbit by apache.
the class SearchIndex method getChangeLogRecords.
/**
* Polls the underlying journal for events of the type ChangeLogRecord that
* happened after a given revision, on a given workspace.
*
* @param revision
* starting revision
* @param workspace
* the workspace name
* @return
*/
private List<ChangeLogRecord> getChangeLogRecords(long revision, final String workspace) {
log.debug("Get changes from the Journal for revision {} and workspace {}.", revision, workspace);
ClusterNode cn = getContext().getClusterNode();
if (cn == null) {
return Collections.emptyList();
}
Journal journal = cn.getJournal();
final List<ChangeLogRecord> events = new ArrayList<ChangeLogRecord>();
ClusterRecordDeserializer deserializer = new ClusterRecordDeserializer();
RecordIterator records = null;
try {
records = journal.getRecords(revision);
while (records.hasNext()) {
Record record = records.nextRecord();
if (!record.getProducerId().equals(cn.getId())) {
continue;
}
ClusterRecord r = null;
try {
r = deserializer.deserialize(record);
} catch (JournalException e) {
log.error("Unable to read revision '" + record.getRevision() + "'.", e);
}
if (r == null) {
continue;
}
r.process(new ClusterRecordProcessor() {
public void process(ChangeLogRecord record) {
String eventW = record.getWorkspace();
if (eventW != null ? eventW.equals(workspace) : workspace == null) {
events.add(record);
}
}
public void process(LockRecord record) {
}
public void process(NamespaceRecord record) {
}
public void process(NodeTypeRecord record) {
}
public void process(PrivilegeRecord record) {
}
public void process(WorkspaceRecord record) {
}
});
}
} catch (JournalException e1) {
log.error(e1.getMessage(), e1);
} finally {
if (records != null) {
records.close();
}
}
return events;
}
use of org.apache.jackrabbit.core.journal.Journal in project jackrabbit by apache.
the class RepositoryConfigurationParser method getJournalFactory.
/**
* Parses journal configuration. Journal configuration uses the following format:
* <pre>
* <Journal class="...">
* <param name="..." value="...">
* ...
* </Journal>
* </pre>
* <p>
* <code>Journal</code> is a {@link #parseBeanConfig(Element,String) bean configuration}
* element.
*
* @param cluster parent cluster element
* @param home repository home directory
* @param id cluster node id
* @return journal factory
* @throws ConfigurationException if the configuration is broken
*/
protected JournalFactory getJournalFactory(final Element cluster, final File home, final String id) throws ConfigurationException {
return new JournalFactory() {
public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
BeanConfig config = parseBeanConfig(cluster, JOURNAL_ELEMENT);
Journal journal = config.newInstance(Journal.class);
if (journal instanceof AbstractJournal) {
((AbstractJournal) journal).setRepositoryHome(home);
}
try {
journal.init(id, resolver);
} catch (JournalException e) {
// TODO: Should JournalException extend RepositoryException?
throw new RepositoryException("Journal initialization failed: " + journal, e);
}
return journal;
}
};
}
Aggregations