@Override public EntityIndexBatch deindex(final SearchEdge searchEdge, final CandidateResult entity) { return deindex( searchEdge, entity.getId(), entity.getVersion() ); } @Override
if(candidateResult.getVersion().timestamp() <= markedVersion.timestamp()){ candidateResult.getVersion(), markedVersion, candidateResult.getId() logger.trace("Candidate version {} is > provided entity version {} for entityId {}. Not" + "adding to candidate results", candidateResult.getVersion(), markedVersion, candidateResult.getId()
final CandidateResult candidateResult = candidate.getCandidateResult(); final Id candidateId = candidateResult.getId(); final UUID candidateVersion = candidateResult.getVersion(); final CandidateResult candidateResult = candidate.getCandidateResult(); final Id candidateId = candidateResult.getId(); final UUID candidateVersion = candidateResult.getVersion();
/** * Validate each candidate results vs the data loaded from cass */ private void validate( final FilterResult<Candidate> filterCandidate ) { final CandidateResult candidateResult = filterCandidate.getValue().getCandidateResult(); final SearchEdge searchEdge = filterCandidate.getValue().getSearchEdge(); final MvccLogEntry logEntry = versionSet.getMaxVersion( candidateResult.getId() ); final UUID candidateVersion = candidateResult.getVersion(); final UUID entityVersion = logEntry.getVersion(); final Id entityId = logEntry.getEntityId(); //entity is newer than ES version if ( UUIDComparator.staticCompare( entityVersion, candidateVersion ) > 0 ) { logger.warn( "Deindexing stale entity on edge {} for entityId {} and version {}", searchEdge, entityId, entityVersion ); batch.deindex( searchEdge, entityId, entityVersion ); return; } //ES is newer than cass, it means we haven't repaired the record in Cass, we don't want to //remove the ES record, since the read in cass should cause a read repair, just ignore if ( UUIDComparator.staticCompare( candidateVersion, entityVersion ) > 0 ) { logger.warn( "Found a newer version in ES over cassandra for edge {} for entityId {} and version {}. Repair should be run", searchEdge, entityId, entityVersion ); } //they're the same add it final FilterResult<Id> result = new FilterResult<>( entityId, filterCandidate.getPath() ); results.add( result ); } }
final SearchEdge searchEdge = candidate.getSearchEdge(); final Id candidateId = candidateResult.getId(); UUID candidateVersion = candidateResult.getVersion();
assertEquals(entity1.getVersion(), candidate1.getVersion());
assertEquals(1, results.size()); assertEquals(newVersion, results.get(0).getVersion());
assertEquals(entity1.getVersion(), candidate1.getVersion()); assertEquals( entity2.getVersion(), candidate2.getVersion() );
@Test public void testDocumentIdPipes() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "zzzcollzzz|users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(zzzcollzzz|users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); }
@Test public void testDocumentId() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); }
@Test public void testAppIdFromDocumentId() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final UUID version = UUIDGenerator.newTimeUUID(); final SearchEdgeImpl searchEdge = new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET ); final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge .getNodeId().getType() + ").edgeName(users).nodeType(TARGET)"; assertEquals( output, expected ); //now parse it final CandidateResult parsedId = parseIndexDocId( output ); assertEquals(version, parsedId.getVersion()); assertEquals(id, parsedId.getId()); final UUID appId = parseAppIdFromIndexDocId(output); assertEquals(appId,applicationScope.getApplication().getUuid()); }