/** * Log an update. Will flush to disk before returning. * * @param o Update argument * @throws IllegalStateException if the current thread does not hold a non-exclusive mutator lock * @throws IOException If errors accessing the file system occur */ public void update(Object o) throws IOException { final Long lockStateVal = lockState.get(); if (lockStateVal == null || lockStateVal == 0) throw new IllegalStateException( "PersistentStrore.update:" + "Must acquire mutator lock before calling update()"); synchronized (this) { log.update(o, true); updateCount++; snapshotHandler.updatePerformed(updateCount); } }
@Override public <T> T snapshot(SnapshotHandler<T> snapshotHandler) throws EngineException { SnapshotIndexCommit snapshotIndexCommit = null; Translog.Snapshot traslogSnapshot = null; rwl.readLock().lock(); try { snapshotIndexCommit = deletionPolicy.snapshot(); traslogSnapshot = translog.snapshot(); } catch (Exception e) { if (snapshotIndexCommit != null) snapshotIndexCommit.release(); throw new SnapshotFailedEngineException(shardId, e); } finally { rwl.readLock().unlock(); } try { return snapshotHandler.snapshot(snapshotIndexCommit, traslogSnapshot); } finally { snapshotIndexCommit.release(); traslogSnapshot.release(); } }