기업 검색엔진 개발의 연결기connector(209)
16604 단어 connector
다음은 DiffingConnectorTraversalManager 클래스와 관련된 방법을 추적하여 이 클래스가 실현되는 방법에서 모니터 관리 대상인 snapshotRepositoryMonitorManager의 관련 방법을 호출하여 그 조작을 실현하였다.
private final DocumentSnapshotRepositoryMonitorManager
snapshotRepositoryMonitorManager;
private final TraversalContextManager traversalContextManager;
/**
* Boolean to mark TraversalManager as invalid.
* It's possible for Connector Manager to keep a reference to
* an outdated TraversalManager (after a new one has been given
* previous TraversalManagers are invalid to use).
*/
private boolean isActive = true;
/**
* Creates a {@link DiffingConnectorTraversalManager}.
*
* @param snapshotRepositoryMonitorManager the
* {@link DocumentSnapshotRepositoryMonitorManager}
* for use accessing a {@link ChangeSource}
* @param traversalContextManager {@link TraversalContextManager}
* that holds the current {@link TraversalContext}
*/
public DiffingConnectorTraversalManager(
DocumentSnapshotRepositoryMonitorManager snapshotRepositoryMonitorManager,
TraversalContextManager traversalContextManager) {
this.snapshotRepositoryMonitorManager = snapshotRepositoryMonitorManager;
this.traversalContextManager = traversalContextManager;
}
resumeTraversal 방법은 모니터 관리 대상 snapshotRepository Monitor Manager를 시작하고 DocumentList 집합으로 되돌려줍니다
/* @Override */
public synchronized DocumentList resumeTraversal(String checkpoint)
throws RepositoryException {
/* Exhaustive list of method's use:
resumeTraversal(null) from startTraversal:
monitors get started from null
resumeTraversal(null) from Connector Manager sometime after startTraversal:
monitors already started from previous resumeTraversal call
resumeTraversal(cp) from Connector Manager without a startTraversal:
means there was a shutdown or turn off
monitors get started from cp; should use state
resumeTraversal(cp) from Connector Manager sometime after some uses:
is most common case; roll
*/
if (isActive()) {
// snapshotRepositoryMonitorManager
if (!snapshotRepositoryMonitorManager.isRunning()) {
snapshotRepositoryMonitorManager.start(checkpoint);
}
return newDocumentList(checkpoint);
} else {
throw new RepositoryException(
"Inactive FileTraversalManager referanced.");
}
}
새 DocumentList 메서드를 사용하여 DocumentList 컬렉션으로 돌아가기
private DocumentList newDocumentList(String checkpoint)
throws RepositoryException {
// CheckpointAndChangeQueue( CheckpointAndChangeQueue snapshotRepositoryMonitorManager )
CheckpointAndChangeQueue checkpointAndChangeQueue =
snapshotRepositoryMonitorManager.getCheckpointAndChangeQueue();
try {
DiffingConnectorDocumentList documentList = new DiffingConnectorDocumentList(
checkpointAndChangeQueue,
CheckpointAndChangeQueue.initializeCheckpointStringIfNull(
checkpoint));
//Map<String, MonitorCheckpoint>
Map<String, MonitorCheckpoint> guaranteesMade =
checkpointAndChangeQueue.getMonitorRestartPoints();
snapshotRepositoryMonitorManager.acceptGuarantees(guaranteesMade);
return new ConfirmActiveDocumentList(documentList);
} catch (IOException e) {
throw new RepositoryException("Failure when making DocumentList.", e);
}
}
DiffingConnectorDocumentList documentList 대상의 구조 함수에는 CheckpointAndChangeQueue checkpointAndChangeQueue 대기열 집합이 봉인되어 있습니다
DiffingConnectorDocumentList 클래스의 전체 구성은 다음과 같습니다.
/**
* An implementation of {@link DocumentList} for the {@link DiffingConnector}.
*
* @since 2.8
*/
public class DiffingConnectorDocumentList implements DocumentList {
private final Iterator<CheckpointAndChange> checkpointAndChangeIterator;
private String checkpoint;
/**
* Creates a document list that returns a batch of documents from the provided
* {@link CheckpointAndChangeQueue}.
*
* @param queue a CheckpointAndChangeQueue containing document changes
* @param checkpoint point into the change queue after which to start
* returning documents
* @throws IOException if persisting fails
*/
public DiffingConnectorDocumentList(CheckpointAndChangeQueue queue,
String checkpoint) throws IOException {
//CheckpointAndChangeQueue queued resume List<CheckpointAndChange>
// DocumentList
List<CheckpointAndChange> guaranteedChanges = queue.resume(checkpoint);
checkpointAndChangeIterator = guaranteedChanges.iterator();
this.checkpoint = checkpoint;
}
/**
* , checkpoint
*/
/* @Override */
public String checkpoint() {
return checkpoint;
}
/* @Override */
public Document nextDocument() throws RepositoryException {
if (checkpointAndChangeIterator.hasNext()) {
CheckpointAndChange checkpointAndChange =
checkpointAndChangeIterator.next();
// checkpoint
checkpoint = checkpointAndChange.getCheckpoint().toString();
return checkpointAndChange.getChange().getDocumentHandle().getDocument();
} else {
return null;
}
}
}
구성 방법에서 매개 변수인 CheckpointAndChangeQueue의resume 방법을 호출하여List
마지막으로 모니터와 연결된 MonitorCheckpoint 객체 매핑 가져오기
//Map<String, MonitorCheckpoint>
Map<String, MonitorCheckpoint> guaranteesMade =
checkpointAndChangeQueue.getMonitorRestartPoints();
그리고 모니터 관리 대상인 snapshot Repository Monitor Manager의accept Guarantees 방법을 호출하여 해당하는 모니터 대상이 모니터 Checkpoint 대상을 수신하고 확인합니다
/**
* CheckpointAndChangeQueue , MonitorCheckpoint
*/
/* @Override */
public void acceptGuarantees(Map<String, MonitorCheckpoint> guarantees) {
for (Map.Entry<String, MonitorCheckpoint> entry : guarantees.entrySet()) {
String monitorName = entry.getKey();
MonitorCheckpoint checkpoint = entry.getValue();
DocumentSnapshotRepositoryMonitor monitor = fileSystemMonitorsByName.get(monitorName);
if (monitor != null) {
// Signal is asynch. Let monitor figure out how to use.
//
monitor.acceptGuarantee(checkpoint);
}
}
}
창고 대상에 대응하는 구체적인 모니터 수신 확인
/**
* [MonitorCheckpoint ]
* @param cp
*/
// Public for DocumentSnapshotRepositoryMonitorTest
@VisibleForTesting
public void acceptGuarantee(MonitorCheckpoint cp) {
snapshotStore.acceptGuarantee(cp);
guaranteeCheckpoint = cp;
}
창고에 대응하는 저장 대상은 처리 체인의 끝에 있다
/**
* MonitorCheckpoint
* @param cp
*/
void acceptGuarantee(MonitorCheckpoint cp) {
long readSnapshotNumber = cp.getSnapshotNumber();
if (readSnapshotNumber < 0) {
throw new IllegalArgumentException("Received invalid snapshot in: " + cp);
}
if (oldestSnapshotToKeep > readSnapshotNumber) {
LOG.warning("Received an older snapshot than " + oldestSnapshotToKeep + ": " + cp);
} else {
oldestSnapshotToKeep = readSnapshotNumber;
}
}
---------------------------------------------------------------------------
본 시리즈 기업 검색엔진 개발의 연결기connector계 본인 오리지널
전재 는 출처 가 블로그 정원 고슴도치 의 온순함 을 밝혀 주십시오
본인 이메일:chenying998179@163#com
본문 링크http://www.cnblogs.com/chenying99/p/3789650.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
BBNA에서 네트워크 커넥터 생성 오류 1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.