use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.
the class ConsistencyComponent method process.
@Override
public void process(ResponseBuilder rb) throws IOException {
SolrQueryRequest req = rb.req;
AlfrescoCoreAdminHandler adminHandler = (AlfrescoCoreAdminHandler) req.getCore().getCoreContainer().getMultiCoreHandler();
boolean isShard = rb.req.getParams().getBool(ShardParams.IS_SHARD, false);
MetadataTracker metaTrkr = adminHandler.getTrackerRegistry().getTrackerForCore(req.getCore().getName(), MetadataTracker.class);
if (metaTrkr != null && !isShard) {
TrackerState metadataTrkrState = metaTrkr.getTrackerState();
long lastIndexedTx = metadataTrkrState.getLastIndexedTxId();
long lastIndexTxCommitTime = metadataTrkrState.getLastIndexedTxCommitTime();
long lastTxIdOnServer = metadataTrkrState.getLastTxIdOnServer();
long transactionsToDo = lastTxIdOnServer - lastIndexedTx;
if (transactionsToDo < 0) {
transactionsToDo = 0;
}
rb.rsp.add("lastIndexedTx", lastIndexedTx);
rb.rsp.add("lastIndexedTxTime", lastIndexTxCommitTime);
rb.rsp.add("txRemaining", transactionsToDo);
}
}
use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.
the class MetadataTrackerTest method doTrackWithNoTransactionsDoesNothing.
@Test
@Ignore("Superseded by AlfrescoSolrTrackerTest")
public void doTrackWithNoTransactionsDoesNothing() throws AuthenticationException, IOException, JSONException, EncoderException {
TrackerState state = new TrackerState();
when(srv.getTrackerInitialState()).thenReturn(state);
when(this.metadataTracker.getTrackerState()).thenReturn(state);
Transactions txs = mock(Transactions.class);
List<Transaction> txsList = new ArrayList<>();
when(txs.getTransactions()).thenReturn(txsList);
when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt(), isNull(ShardState.class))).thenReturn(txs);
when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt(), any(ShardState.class))).thenReturn(txs);
when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt())).thenReturn(txs);
this.metadataTracker.doTrack();
verify(srv, never()).commit();
}
use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.
the class MetadataTracker method getShardState.
/**
* @return
*/
private ShardState getShardState() {
TrackerState state = super.getTrackerState();
ShardState shardstate = ShardStateBuilder.shardState().withMaster(isMaster).withLastUpdated(System.currentTimeMillis()).withLastIndexedChangeSetCommitTime(state.getLastIndexedChangeSetCommitTime()).withLastIndexedChangeSetId(state.getLastIndexedChangeSetId()).withLastIndexedTxCommitTime(state.getLastIndexedTxCommitTime()).withLastIndexedTxId(state.getLastIndexedTxId()).withShardInstance().withBaseUrl(infoSrv.getBaseUrl()).withPort(infoSrv.getPort()).withHostName(infoSrv.getHostName()).withShard().withInstance(shardInstance).withFloc().withNumberOfShards(shardCount).withAddedStoreRef(storeRef).withTemplate(shardTemplate).withHasContent(transformContent).withShardMethod(ShardMethodEnum.getShardMethod(shardMethod)).endFloc().endShard().endShardInstance().build();
return shardstate;
}
use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.
the class MetadataTracker method trackRepository.
private void trackRepository() throws IOException, AuthenticationException, JSONException, EncoderException {
checkShutdown();
if (!isMaster && isSlave) {
// Dynamic registration
ShardState shardstate = getShardState();
client.getTransactions(0L, null, 0L, null, 0, shardstate);
return;
}
// Check we are tracking the correct repository
TrackerState state = super.getTrackerState();
if (state.getTrackerCycles() == 0) {
// We have a new tracker state so do the checks.
checkRepoAndIndexConsistency(state);
}
if (docRouter instanceof DBIDRangeRouter) {
DBIDRangeRouter dbidRangeRouter = (DBIDRangeRouter) docRouter;
long indexCap = infoSrv.getIndexCap();
long endRange = dbidRangeRouter.getEndRange();
assert (indexCap == -1 || indexCap >= endRange);
if (indexCap > endRange) {
dbidRangeRouter.setExpanded(true);
dbidRangeRouter.setEndRange(indexCap);
}
dbidRangeRouter.setInitialized(true);
}
checkShutdown();
trackTransactions();
}
use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.
the class AclTrackerTest method setUp.
@Before
public void setUp() throws Exception {
trackerState = new TrackerState();
// Nothing would happen if it were already running.
trackerState.setRunning(false);
Properties props = createProperties();
// Spy in order to stub some methods and verify others. Note: non-stubbed methods go to the real class.
tracker = spy(new AclTracker(props, client, "core-name", informationServer));
}
Aggregations