From c8f7436ab638a63d58d63656f4f8394dfeff21a8 Mon Sep 17 00:00:00 2001 From: laa Date: Thu, 12 Oct 2017 11:10:34 +0300 Subject: [PATCH] Code observations were fixed --- .../orient/client/remote/OStorageRemote.java | 8 +- .../document/ODatabaseDocumentAbstract.java | 7 +- .../core/index/sbtree/local/OSBTree.java | 2 - .../local/OSBTreeBonsaiLocal.java | 2 - .../core/storage/OAutoshardedStorage.java | 2 - .../orient/core/storage/OCluster.java | 11 +- .../core/storage/OClusterEntryIterator.java | 3 + .../core/storage/OPhysicalPosition.java | 14 +- .../orient/core/storage/ORawBuffer.java | 4 +- .../orient/core/storage/OStorage.java | 7 +- .../orient/core/storage/OStorageAbstract.java | 20 +- .../core/storage/OStorageOperationResult.java | 1 - .../core/storage/cache/OCacheEntryImpl.java | 26 +- .../core/storage/cache/OCachePointer.java | 5 +- .../cache/OPageDataVerificationError.java | 8 +- .../orient/core/storage/cache/OReadCache.java | 4 +- .../core/storage/cache/OSnowFlakeIdGen.java | 4 +- .../core/storage/cache/OWriteCache.java | 8 +- .../core/storage/cache/local/OWOWCache.java | 42 +-- .../storage/cache/local/OWOWCacheMXBean.java | 37 --- .../core/storage/cache/local/PageGroup.java | 40 --- .../cache/local/twoq/ConcurrentLRUList.java | 14 +- .../storage/cache/local/twoq/O2QCache.java | 26 +- .../cache/local/twoq/O2QCacheMXBean.java | 35 --- .../orient/core/storage/fs/OFile.java | 22 +- .../orient/core/storage/fs/OFileClassic.java | 85 +----- .../impl/local/OAbstractPaginatedStorage.java | 9 +- .../impl/local/OLowDiskSpaceInformation.java | 4 +- .../storage/impl/local/OMicroTransaction.java | 10 +- .../impl/local/OSingleFileSegment.java | 15 +- .../local/OStorageConfigurationSegment.java | 2 +- .../impl/local/OStorageVariableParser.java | 9 +- .../impl/local/paginated/OClusterPage.java | 22 +- .../local/paginated/OClusterPositionMap.java | 38 +-- .../paginated/OClusterPositionMapBucket.java | 22 +- .../paginated/OLocalPaginatedStorage.java | 2 +- .../impl/local/paginated/OOfflineCluster.java | 6 +- .../paginated/OOfflineClusterException.java | 1 - .../local/paginated/OPaginatedCluster.java | 57 ++-- .../paginated/OPaginatedClusterState.java | 8 +- .../paginated/OPaginatedStorageDirtyFlag.java | 6 +- .../paginated/ORecordOperationMetadata.java | 2 +- .../ORecordSerializationContext.java | 7 +- .../ORecordSerializationOperation.java | 1 - .../atomicoperations/OAtomicOperation.java | 75 ++--- .../OAtomicOperationMetadata.java | 1 + .../OAtomicOperationsManager.java | 5 +- .../OAtomicOperationsMangerMXBean.java | 3 - .../atomicoperations/OCacheEntryChanges.java | 11 +- .../paginated/base/ODurableComponent.java | 11 +- .../paginated/wal/OAbstractWALRecord.java | 2 + .../paginated/wal/OAbstractWriteAheadLog.java | 12 +- .../paginated/wal/OAtomicUnitEndRecord.java | 8 +- .../paginated/wal/OClusterAwareWALRecord.java | 29 -- .../impl/local/paginated/wal/ODirtyPage.java | 81 ------ .../paginated/wal/ODiskWriteAheadLog.java | 6 +- .../impl/local/paginated/wal/OLogSegment.java | 4 +- .../local/paginated/wal/OLogSegmentV1.java | 4 +- .../local/paginated/wal/OLogSegmentV2.java | 4 +- .../paginated/wal/OMemoryWriteAheadLog.java | 2 +- .../wal/OOperationUnitBodyRecord.java | 38 +-- .../local/paginated/wal/OOperationUnitId.java | 9 +- .../impl/local/paginated/wal/OWALChanges.java | 2 +- .../local/paginated/wal/OWALChangesTree.java | 122 ++++---- .../wal/OWALPageBrokenException.java | 1 - .../paginated/wal/OWALPageChangesPortion.java | 26 +- .../paginated/wal/OWALRecordsFactory.java | 8 +- .../local/paginated/wal/OWriteAheadLog.java | 4 +- .../statistic/OClusterCountersHolder.java | 36 +-- .../impl/local/statistic/OOperation.java | 1 + .../OPerformanceStatisticManager.java | 70 ++--- .../OPerformanceStatisticManagerMBean.java | 110 ++++---- .../OSessionStoragePerformanceStatistic.java | 264 ++++++++---------- .../memory/ODirectMemoryOnlyDiskCache.java | 4 +- .../impl/memory/ODirectMemoryStorage.java | 2 +- .../orient/core/PostponedEngineStartTest.java | 4 +- .../ODropClusterStatementExecutionTest.java | 4 +- .../core/storage/StorageNamingTests.java | 5 +- .../distributed/impl/ODistributedStorage.java | 10 +- 79 files changed, 630 insertions(+), 1006 deletions(-) mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/OAutoshardedStorage.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/OCluster.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCacheEntryImpl.java delete mode 100755 core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCacheMXBean.java delete mode 100755 core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/PageGroup.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/ConcurrentLRUList.java delete mode 100644 core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCacheMXBean.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OLowDiskSpaceInformation.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OMicroTransaction.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageVariableParser.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineCluster.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedStorageDirtyFlag.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordOperationMetadata.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationOperation.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationMetadata.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OCacheEntryChanges.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWriteAheadLog.java delete mode 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OClusterAwareWALRecord.java delete mode 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODirtyPage.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChanges.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageChangesPortion.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OClusterCountersHolder.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OOperation.java mode change 100644 => 100755 core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java mode change 100644 => 100755 core/src/test/java/com/orientechnologies/orient/core/sql/executor/ODropClusterStatementExecutionTest.java diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java index b261e8aab91..5013056d780 100755 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java @@ -82,7 +82,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; /** @@ -977,12 +976,11 @@ public void setDefaultClusterId(int defaultClusterId) { this.defaultClusterId = defaultClusterId; } - public int addCluster(final String iClusterName, boolean forceListBased, final Object... iArguments) { - return addCluster(iClusterName, -1, forceListBased, iArguments); + public int addCluster(final String iClusterName, final Object... iArguments) { + return addCluster(iClusterName, -1, iArguments); } - public int addCluster(final String iClusterName, final int iRequestedId, final boolean forceListBased, - final Object... iParameters) { + public int addCluster(final String iClusterName, final int iRequestedId, final Object... iParameters) { OAddClusterRequest request = new OAddClusterRequest(iRequestedId, iClusterName); OAddClusterResponse response = networkOperationNoRetry(request, "Error on add new cluster"); addNewClusterToConfiguration(response.getClusterId(), iClusterName); diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentAbstract.java index f4bdf6f8226..3ae8703a9b6 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/document/ODatabaseDocumentAbstract.java @@ -56,7 +56,6 @@ import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.OMetadataDefault; import com.orientechnologies.orient.core.metadata.schema.OClass; -import com.orientechnologies.orient.core.metadata.schema.OImmutableClass; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OSchemaProxy; import com.orientechnologies.orient.core.metadata.security.*; @@ -69,9 +68,7 @@ import com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory; import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.executor.OResultSet; -import com.orientechnologies.orient.core.sql.parser.OLocalResultSetLifecycleDecorator; import com.orientechnologies.orient.core.storage.*; -import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage; import com.orientechnologies.orient.core.storage.impl.local.OFreezableStorageComponent; import com.orientechnologies.orient.core.storage.impl.local.OMicroTransaction; import com.orientechnologies.orient.core.storage.impl.local.paginated.OOfflineClusterException; @@ -922,13 +919,13 @@ public boolean isClosed() { @Override public int addCluster(final String iClusterName, final Object... iParameters) { checkIfActive(); - return getStorage().addCluster(iClusterName, false, iParameters); + return getStorage().addCluster(iClusterName, iParameters); } @Override public int addCluster(final String iClusterName, final int iRequestedId, final Object... iParameters) { checkIfActive(); - return getStorage().addCluster(iClusterName, iRequestedId, false, iParameters); + return getStorage().addCluster(iClusterName, iRequestedId, iParameters); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/sbtree/local/OSBTree.java b/core/src/main/java/com/orientechnologies/orient/core/index/sbtree/local/OSBTree.java index 14138cf934c..f857b693c9d 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/sbtree/local/OSBTree.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/sbtree/local/OSBTree.java @@ -440,8 +440,6 @@ public void close(boolean flush) { if (nullPointerSupport) readCache.closeFile(nullBucketFileId, flush, writeCache); - } catch (IOException e) { - throw OException.wrapException(new OSBTreeException("Error during close of index " + getName(), this), e); } finally { releaseExclusiveLock(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/sbtreebonsai/local/OSBTreeBonsaiLocal.java b/core/src/main/java/com/orientechnologies/orient/core/index/sbtreebonsai/local/OSBTreeBonsaiLocal.java index 00cad308a52..4a9fc7369b2 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/sbtreebonsai/local/OSBTreeBonsaiLocal.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/sbtreebonsai/local/OSBTreeBonsaiLocal.java @@ -295,8 +295,6 @@ public void close(boolean flush) { Lock lock = FILE_LOCK_MANAGER.acquireExclusiveLock(fileId); try { readCache.closeFile(fileId, flush, writeCache); - } catch (IOException e) { - throw OException.wrapException(new OSBTreeBonsaiLocalException("Error during close of index " + getName(), this), e); } finally { lock.unlock(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OAutoshardedStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OAutoshardedStorage.java old mode 100644 new mode 100755 index b4f8acb7910..3a8f7e76565 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OAutoshardedStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OAutoshardedStorage.java @@ -42,8 +42,6 @@ public interface OAutoshardedStorage { /** * Check if the distributed need to run only as local env - * - * @return */ boolean isLocalEnv(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OCluster.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OCluster.java old mode 100644 new mode 100755 index 809c484465e..38cbc932f99 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OCluster.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OCluster.java @@ -28,7 +28,7 @@ public interface OCluster { enum ATTRIBUTES { - NAME, USE_WAL, RECORD_GROW_FACTOR, RECORD_OVERFLOW_GROW_FACTOR, CONFLICTSTRATEGY, STATUS, ENCRYPTION + NAME, RECORD_GROW_FACTOR, RECORD_OVERFLOW_GROW_FACTOR, CONFLICTSTRATEGY, STATUS, ENCRYPTION } void configure(OStorage iStorage, int iId, String iClusterName, Object... iParameters) throws IOException; @@ -54,7 +54,6 @@ enum ATTRIBUTES { /** * Truncates the cluster content. All the entries will be removed. * - * @throws IOException */ void truncate() throws IOException; @@ -64,8 +63,6 @@ enum ATTRIBUTES { * @param recordType the type of record of which allocate the position. * * @return the allocated position. - * - * @throws IOException */ OPhysicalPosition allocatePosition(byte recordType) throws IOException; @@ -78,8 +75,6 @@ enum ATTRIBUTES { * @param allocatedPosition the eventual allocated position or null if there is no allocated position. * * @return the position where the record si created. - * - * @throws IOException */ OPhysicalPosition createRecord(byte[] content, int recordVersion, byte recordType, OPhysicalPosition allocatedPosition) throws IOException; @@ -101,8 +96,6 @@ OPhysicalPosition createRecord(byte[] content, int recordVersion, byte recordTyp /** * Fills and return the PhysicalPosition object received as parameter with the physical position of logical record iPosition - * - * @throws IOException */ OPhysicalPosition getPhysicalPosition(OPhysicalPosition iPPosition) throws IOException; @@ -124,8 +117,6 @@ OPhysicalPosition createRecord(byte[] content, int recordVersion, byte recordTyp /** * Returns the size of the records contained in the cluster in bytes. - * - * @return */ long getRecordsSize() throws IOException; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OClusterEntryIterator.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OClusterEntryIterator.java index f42f732c007..ff97ccf3f3b 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OClusterEntryIterator.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OClusterEntryIterator.java @@ -47,6 +47,7 @@ public OClusterEntryIterator(final OCluster iCluster) { positionsIndex = -1; } + @Override public boolean hasNext() { if (min == ORID.CLUSTER_POS_INVALID) return false; @@ -57,6 +58,7 @@ public boolean hasNext() { return positionsToProcess.length != 0; } + @Override public OPhysicalPosition next() { try { if (positionsIndex == -1) { @@ -81,6 +83,7 @@ public OPhysicalPosition next() { } } + @Override public void remove() { throw new UnsupportedOperationException("remove"); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OPhysicalPosition.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OPhysicalPosition.java index d4e12ae7bfd..2cdb2b4a682 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OPhysicalPosition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OPhysicalPosition.java @@ -29,7 +29,7 @@ import java.io.ObjectOutput; public class OPhysicalPosition implements OSerializableStream, Externalizable { - public static final int binarySize = OBinaryProtocol.SIZE_LONG + OBinaryProtocol.SIZE_BYTE + OBinaryProtocol.SIZE_INT + private static final int binarySize = OBinaryProtocol.SIZE_LONG + OBinaryProtocol.SIZE_BYTE + OBinaryProtocol.SIZE_INT + OBinaryProtocol.SIZE_INT; public long clusterPosition; public byte recordType; @@ -52,11 +52,7 @@ public OPhysicalPosition(final long iClusterPosition, final int iVersion) { recordVersion = iVersion; } - public static int binarySize() { - return binarySize; - } - - public void copyTo(final OPhysicalPosition iDest) { + private void copyTo(final OPhysicalPosition iDest) { iDest.clusterPosition = clusterPosition; iDest.recordType = recordType; iDest.recordVersion = recordVersion; @@ -72,6 +68,7 @@ public String toString() { return "rid(?:" + clusterPosition + ") record(type:" + recordType + " size:" + recordSize + " v:" + recordVersion + ")"; } + @Override public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException { int pos = 0; @@ -89,8 +86,9 @@ public OSerializableStream fromStream(final byte[] iStream) throws OSerializatio return this; } + @Override public byte[] toStream() throws OSerializationException { - final byte[] buffer = new byte[binarySize()]; + final byte[] buffer = new byte[binarySize]; int pos = 0; OBinaryProtocol.long2bytes(clusterPosition, buffer, pos); @@ -126,6 +124,7 @@ public int hashCode() { return result; } + @Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeLong(clusterPosition); out.writeByte(recordType); @@ -133,6 +132,7 @@ public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(recordVersion); } + @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { clusterPosition = in.readLong(); recordType = in.readByte(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/ORawBuffer.java b/core/src/main/java/com/orientechnologies/orient/core/storage/ORawBuffer.java index 938acff2920..80463020459 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/ORawBuffer.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/ORawBuffer.java @@ -48,8 +48,6 @@ public ORawBuffer(final byte[] buffer, final int version, final byte recordType) /** * Creates a new object by the record received. - * - * @param iRecord */ public ORawBuffer(final ORecord iRecord) { this.buffer = iRecord.toStream(); @@ -57,12 +55,14 @@ public ORawBuffer(final ORecord iRecord) { this.recordType = ORecordInternal.getRecordType(iRecord); } + @Override public void readExternal(final ObjectInput iInput) throws IOException, ClassNotFoundException { super.readExternal(iInput); version = iInput.readInt(); recordType = iInput.readByte(); } + @Override public void writeExternal(final ObjectOutput iOutput) throws IOException { super.writeExternal(iOutput); iOutput.writeInt(version); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorage.java index a4b1bb57918..7c05eab2f50 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorage.java @@ -123,15 +123,14 @@ OStorageOperationResult updateRecord(ORecordId iRecordId, boolean updat * * @param iClusterName name of the cluster */ - int addCluster(String iClusterName, boolean forceListBased, Object... iParameters); + int addCluster(String iClusterName, Object... iParameters); /** * Add a new cluster into the storage. - * - * @param iClusterName name of the cluster + * @param iClusterName name of the cluster * @param iRequestedId requested id of the cluster */ - int addCluster(String iClusterName, int iRequestedId, boolean forceListBased, Object... iParameters); + int addCluster(String iClusterName, int iRequestedId, Object... iParameters); boolean dropCluster(String iClusterName, final boolean iTruncate); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java index 37b9b6669fa..783298e13a4 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageAbstract.java @@ -25,8 +25,6 @@ import com.orientechnologies.common.exception.OException; import com.orientechnologies.orient.core.Orient; import com.orientechnologies.orient.core.config.OStorageConfiguration; -import com.orientechnologies.orient.core.db.OLiveQueryMonitor; -import com.orientechnologies.orient.core.db.OLiveQueryResultListener; import com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory; import com.orientechnologies.orient.core.exception.OStorageException; import com.orientechnologies.orient.core.record.ORecordVersionHelper; @@ -67,10 +65,10 @@ public abstract class OStorageAbstract implements OStorage, OSharedContainer { protected volatile OStorageConfiguration configuration; protected volatile OCurrentStorageComponentsFactory componentsFactory; protected String name; - protected AtomicLong version = new AtomicLong(); + private final AtomicLong version = new AtomicLong(); protected volatile STATUS status = STATUS.CLOSED; - protected final OSharedContainerImpl sharedContainer = new OSharedContainerImpl(); + private final OSharedContainerImpl sharedContainer = new OSharedContainerImpl(); public OStorageAbstract(final String name, final String iURL, final String mode) { this.name = normalizeName(name); @@ -105,36 +103,45 @@ protected String normalizeName(String name) { } } + @Override public abstract OCluster getClusterByName(final String iClusterName); + @Override public OStorage getUnderlying() { return this; } + @Override public OStorageConfiguration getConfiguration() { return configuration; } + @Override public boolean isClosed() { return status == STATUS.CLOSED; } + @Override public boolean checkForRecordValidity(final OPhysicalPosition ppos) { return ppos != null && !ORecordVersionHelper.isTombstone(ppos.recordVersion); } + @Override public String getName() { return name; } + @Override public String getURL() { return url; } + @Override public void close() { close(false, false); } + @Override public void close(final boolean iForce, boolean onDelete) { sharedContainer.clearResources(); } @@ -157,14 +164,17 @@ public T getResource(String iName, Callable iCallback) { /** * Returns current storage's version as serial. */ + @Override public long getVersion() { return version.get(); } + @Override public boolean dropCluster(final String iClusterName, final boolean iTruncate) { return dropCluster(getClusterIdByName(iClusterName), iTruncate); } + @Override public long countRecords() { long tot = 0; @@ -175,6 +185,7 @@ public long countRecords() { return tot; } + @Override public V callInLock(final Callable iCallable, final boolean iExclusiveLock) { stateLock.acquireReadLock(); try { @@ -195,6 +206,7 @@ public String toString() { return url != null ? url : "?"; } + @Override public STATUS getStatus() { return status; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageOperationResult.java b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageOperationResult.java index 89fc8b6f61a..a2377dbb331 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageOperationResult.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/OStorageOperationResult.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -import java.util.Arrays; /** * This class represent CRUD operation result RET is the actual result Stores addition information about command execution process diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCacheEntryImpl.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCacheEntryImpl.java old mode 100644 new mode 100755 index 7d879e67c8e..f6fd28923bd --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCacheEntryImpl.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCacheEntryImpl.java @@ -6,12 +6,12 @@ * Created by tglman on 23/06/16. */ public class OCacheEntryImpl implements OCacheEntry{ - OCachePointer dataPointer; - final long fileId; - final long pageIndex; + private OCachePointer dataPointer; + private final long fileId; + private final long pageIndex; - boolean dirty; - int usagesCount; + private boolean dirty; + private int usagesCount; public OCacheEntryImpl(long fileId, long pageIndex, OCachePointer dataPointer, boolean dirty) { this.fileId = fileId; @@ -21,58 +21,72 @@ public OCacheEntryImpl(long fileId, long pageIndex, OCachePointer dataPointer, b this.dirty = dirty; } + @Override public void markDirty() { this.dirty = true; } + @Override public void clearDirty() { this.dirty = false; } + @Override public boolean isDirty() { return dirty; } + @Override public OCachePointer getCachePointer() { return dataPointer; } + @Override public void clearCachePointer() { dataPointer = null; } + @Override public void setCachePointer(OCachePointer cachePointer) { this.dataPointer = cachePointer; } + @Override public long getFileId() { return fileId; } + @Override public long getPageIndex() { return pageIndex; } + @Override public void acquireExclusiveLock() { dataPointer.acquireExclusiveLock(); } + @Override public void releaseExclusiveLock() { dataPointer.releaseExclusiveLock(); } + @Override public void acquireSharedLock() { dataPointer.acquireSharedLock(); } + @Override public void releaseSharedLock() { dataPointer.releaseSharedLock(); } + @Override public int getUsagesCount() { return usagesCount; } + @Override public void incrementUsages() { usagesCount++; } @@ -82,10 +96,12 @@ public void incrementUsages() { * * @return Whether lock acquired on current entry */ + @Override public boolean isLockAcquiredByCurrentThread() { return dataPointer.isLockAcquiredByCurrentThread(); } + @Override public void decrementUsages() { usagesCount--; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCachePointer.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCachePointer.java index 8f846f8a763..96f238c9cfe 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCachePointer.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OCachePointer.java @@ -21,7 +21,6 @@ import com.orientechnologies.common.directmemory.OByteBufferPool; import com.orientechnologies.common.log.OLogManager; -import com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber; import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicInteger; @@ -249,6 +248,7 @@ public void releaseSharedLock() { readWriteLock.readLock().unlock(); } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") public boolean tryAcquireSharedLock() { return readWriteLock.readLock().tryLock(); } @@ -290,7 +290,7 @@ public boolean equals(Object o) { buffer.position(0); that.buffer.position(0); - if (buffer != null ? !buffer.equals(that.buffer) : that.buffer != null) + if (!buffer.equals(that.buffer)) return false; return true; @@ -311,6 +311,7 @@ private long composeReadersWriters(int readers, int writers) { } private int getReaders(long readersWriters) { + //noinspection PointlessBitwiseExpression return (int) (readersWriters & READERS_MASK); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OPageDataVerificationError.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OPageDataVerificationError.java index f0e447494ef..5cd183f0156 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OPageDataVerificationError.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OPageDataVerificationError.java @@ -25,10 +25,10 @@ * @since 25.04.13 */ public class OPageDataVerificationError { - public final boolean incorrectMagicNumber; - public final boolean incorrectCheckSum; - public final long pageIndex; - public final String fileName; + private final boolean incorrectMagicNumber; + private final boolean incorrectCheckSum; + private final long pageIndex; + private final String fileName; public OPageDataVerificationError(boolean incorrectMagicNumber, boolean incorrectCheckSum, long pageIndex, String fileName) { this.incorrectMagicNumber = incorrectMagicNumber; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OReadCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OReadCache.java index 4c34068dc83..bdbc9052285 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OReadCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OReadCache.java @@ -74,7 +74,7 @@ OCacheEntry loadForRead(long fileId, long pageIndex, boolean checkPinnedPages, O void releaseFromWrite(OCacheEntry cacheEntry, OWriteCache writeCache); - void pinPage(OCacheEntry cacheEntry) throws IOException; + void pinPage(OCacheEntry cacheEntry); OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, boolean verifyChecksums) throws IOException; @@ -84,7 +84,7 @@ OCacheEntry loadForRead(long fileId, long pageIndex, boolean checkPinnedPages, O void truncateFile(long fileId, OWriteCache writeCache) throws IOException; - void closeFile(long fileId, boolean flush, OWriteCache writeCache) throws IOException; + void closeFile(long fileId, boolean flush, OWriteCache writeCache); void deleteFile(long fileId, OWriteCache writeCache) throws IOException; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OSnowFlakeIdGen.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OSnowFlakeIdGen.java index 5473abea2b0..5006674718f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OSnowFlakeIdGen.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OSnowFlakeIdGen.java @@ -25,8 +25,8 @@ public class OSnowFlakeIdGen implements OWriteCacheIdGen { private long lastTs; private final SecureRandom rnd; - private int sequenceCounter = 1; - private byte[] rndBytes = new byte[2]; + private int sequenceCounter = 1; + private final byte[] rndBytes = new byte[2]; public OSnowFlakeIdGen() { rnd = new SecureRandom(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OWriteCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OWriteCache.java index 3fde3201c43..16980b6ad24 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OWriteCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/OWriteCache.java @@ -49,7 +49,7 @@ public interface OWriteCache { void removeLowDiskSpaceListener(OLowDiskSpaceListener listener); - long bookFileId(String fileName) throws IOException; + long bookFileId(String fileName); /** * Registers new file in write cache and returns file id assigned to this file. @@ -100,7 +100,7 @@ OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boolean ad void flush(); - long getFilledUpTo(long fileId) throws IOException; + long getFilledUpTo(long fileId); long getExclusiveWriteCachePagesSize(); @@ -120,7 +120,7 @@ OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boolean ad long[] close() throws IOException; - void close(long fileId, boolean flush) throws IOException; + void close(long fileId, boolean flush); OPageDataVerificationError[] checkStoredPages(OCommandOutputListener commandOutputListener); @@ -214,7 +214,7 @@ OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boolean ad OLogSequenceNumber getMinimalNotFlushedLSN(); - void updateDirtyPagesTable(OCachePointer pointer) throws IOException; + void updateDirtyPagesTable(OCachePointer pointer); OPerformanceStatisticManager getPerformanceStatisticManager(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java index 11936636a1f..eb2f0e3695c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCache.java @@ -670,7 +670,7 @@ public void run() { } @Override - public long bookFileId(String fileName) throws IOException { + public long bookFileId(String fileName) { filesLock.acquireWriteLock(); try { final Integer fileId = nameIdMap.get(fileName); @@ -828,7 +828,7 @@ public OLogSequenceNumber getMinimalNotFlushedLSN() { } @Override - public void updateDirtyPagesTable(OCachePointer pointer) throws IOException { + public void updateDirtyPagesTable(OCachePointer pointer) { if (writeAheadLog == null) return; @@ -1269,7 +1269,7 @@ public void flush() { } @Override - public long getFilledUpTo(long fileId) throws IOException { + public long getFilledUpTo(long fileId) { final int intId = extractFileId(fileId); fileId = composeFileId(id, intId); @@ -1470,7 +1470,7 @@ public long[] close() throws IOException { } @Override - public void close(long fileId, boolean flush) throws IOException { + public void close(long fileId, boolean flush) { final int intId = extractFileId(fileId); fileId = composeFileId(id, intId); @@ -1652,14 +1652,14 @@ public long[] delete() throws IOException { } } - final long[] fids = new long[result.size()]; + final long[] fIds = new long[result.size()]; int n = 0; for (Long fid : result) { - fids[n] = fid; + fIds[n] = fid; n++; } - return fids; + return fIds; } @Override @@ -2417,10 +2417,10 @@ public Void call() throws Exception { } private void flushExclusivePagesIfNeeded() throws IOException, InterruptedException { - long ewcs = exclusiveWriteCacheSize.get(); + long ewcSize = exclusiveWriteCacheSize.get(); - assert ewcs >= 0; - double exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + assert ewcSize >= 0; + double exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; if (exclusiveWriteCacheThreshold > EXCLUSIVE_PAGES_BOUNDARY) { flushExclusiveWriteCache(); @@ -2505,10 +2505,10 @@ public void run() { } private int flushExclusivePagesIfNeeded(int flushedPages) throws IOException, InterruptedException { - long ewcs = exclusiveWriteCacheSize.get(); + long ewcSize = exclusiveWriteCacheSize.get(); - assert ewcs >= 0; - double exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + assert ewcSize >= 0; + double exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; if (exclusiveWriteCacheThreshold > EXCLUSIVE_PAGES_BOUNDARY) { if (!flushMode.equals(FLUSH_MODE.EXCLUSIVE)) { @@ -2516,8 +2516,8 @@ private int flushExclusivePagesIfNeeded(int flushedPages) throws IOException, In flushedPages += flushExclusiveWriteCache(); - ewcs = exclusiveWriteCacheSize.get(); - exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + ewcSize = exclusiveWriteCacheSize.get(); + exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; if (exclusiveWriteCacheThreshold <= EXCLUSIVE_PAGES_BOUNDARY) { flushMode = FLUSH_MODE.IDLE; @@ -2525,8 +2525,8 @@ private int flushExclusivePagesIfNeeded(int flushedPages) throws IOException, In } else { flushedPages += flushExclusiveWriteCache(); - ewcs = exclusiveWriteCacheSize.get(); - exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + ewcSize = exclusiveWriteCacheSize.get(); + exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; if (exclusiveWriteCacheThreshold <= EXCLUSIVE_PAGES_BOUNDARY) { flushMode = FLUSH_MODE.IDLE; @@ -2719,8 +2719,8 @@ private int flushWriteCacheFromMinLSN() throws IOException, InterruptedException } private void releaseExclusiveLatch() { - final long ewcs = exclusiveWriteCacheSize.get(); - double exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + final long ewcSize = exclusiveWriteCacheSize.get(); + double exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; if (exclusiveWriteCacheThreshold <= EXCLUSIVE_BOUNDARY_UNLOCK_LIMIT) { final CountDownLatch latch = exclusivePagesLimitLatch.get(); @@ -2807,8 +2807,8 @@ private int flushExclusiveWriteCache() throws IOException, InterruptedException int flushedPages = 0; - long ewcs = exclusiveWriteCacheSize.get(); - double exclusiveWriteCacheThreshold = ((double) ewcs) / exclusiveWriteCacheMaxSize; + long ewcSize = exclusiveWriteCacheSize.get(); + double exclusiveWriteCacheThreshold = ((double) ewcSize) / exclusiveWriteCacheMaxSize; double flushThreshold = exclusiveWriteCacheThreshold - EXCLUSIVE_PAGES_BOUNDARY; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCacheMXBean.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCacheMXBean.java deleted file mode 100755 index 070b51856fc..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/OWOWCacheMXBean.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.storage.cache.local; - -import java.util.Date; - -public interface OWOWCacheMXBean { - long getWriteCacheSize(); - - long getWriteCacheSizeInMB(); - - double getWriteCacheSizeInGB(); - - long getExclusiveWriteCacheSize(); - - long getExclusiveWriteCacheSizeInMB(); - - double getExclusiveWriteCacheSizeInGB(); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/PageGroup.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/PageGroup.java deleted file mode 100755 index 2465a193c1e..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/PageGroup.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.storage.cache.local; - -import com.orientechnologies.orient.core.storage.cache.OCachePointer; - -/** - * @author Andrey Lomakin (a.lomakin-at-orientdb.com) - * @since 7/24/13 - */ -class PageGroup { - public final OCachePointer page; - - public volatile boolean recencyBit; - public final long creationTime; - - PageGroup(long creationTime, OCachePointer page) { - this.recencyBit = true; - this.creationTime = creationTime; - this.page = page; - } -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/ConcurrentLRUList.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/ConcurrentLRUList.java old mode 100644 new mode 100755 index 507b80d6742..b6a47f61215 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/ConcurrentLRUList.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/ConcurrentLRUList.java @@ -38,17 +38,19 @@ */ public class ConcurrentLRUList implements LRUList { + @SuppressWarnings("CanBeFinal") private static boolean assertionsEnabled; static { + //noinspection AssertWithSideEffects,ConstantConditions assert assertionsEnabled = true; } - private final ConcurrentHashMap cache = new ConcurrentHashMap(); + private final ConcurrentHashMap cache = new ConcurrentHashMap<>(); private final ListNode headReference = new ListNode(null, true); - private final AtomicReference tailReference = new AtomicReference(headReference); + private final AtomicReference tailReference = new AtomicReference<>(headReference); - private final ConcurrentLinkedQueue trash = new ConcurrentLinkedQueue(); + private final ConcurrentLinkedQueue trash = new ConcurrentLinkedQueue<>(); private final int minTrashSize = Runtime.getRuntime().availableProcessors() * 4; private final AtomicBoolean purgeInProgress = new AtomicBoolean(); @@ -426,7 +428,7 @@ public int hashCode() { } private static class LRUEntry { - private final AtomicReference listNode = new AtomicReference(); + private final AtomicReference listNode = new AtomicReference<>(); private final CacheKey key; private volatile OCacheEntry entry; @@ -441,8 +443,8 @@ private LRUEntry(CacheKey key, OCacheEntry entry) { private static class ListNode { private volatile LRUEntry entry; - private final AtomicReference next = new AtomicReference(); - private final AtomicReference previous = new AtomicReference(); + private final AtomicReference next = new AtomicReference<>(); + private final AtomicReference previous = new AtomicReference<>(); private final boolean isDummy; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCache.java index 681c3a570e6..c09e08fffe2 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCache.java @@ -312,7 +312,7 @@ private void doRelease(OCacheEntry cacheEntry) { } @Override - public void pinPage(final OCacheEntry cacheEntry) throws IOException { + public void pinPage(final OCacheEntry cacheEntry) { Lock fileLock; Lock pageLock; @@ -548,6 +548,7 @@ public OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, boolean } } + @Override public void clear() { cacheLock.acquireWriteLock(); try { @@ -626,7 +627,7 @@ private void clearFile(long fileId) { } @Override - public void closeFile(long fileId, boolean flush, OWriteCache writeCache) throws IOException { + public void closeFile(long fileId, boolean flush, OWriteCache writeCache) { fileId = OAbstractWriteCache.checkFileIdCompatibility(writeCache.getId(), fileId); Lock fileLock; @@ -705,6 +706,7 @@ public void closeStorage(OWriteCache writeCache) throws IOException { * * @see #closeStorage(OWriteCache) */ + @Override public void loadCacheState(final OWriteCache writeCache) { if (!OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE.getValueAsBoolean()) { return; @@ -744,9 +746,9 @@ public void loadCacheState(final OWriteCache writeCache) { } } - } catch (OLoadCacheStateException lcse) { + } catch (OLoadCacheStateException lcsException) { OLogManager.instance() - .warn(this, "Cannot restore state of cache for storage placed under " + writeCache.getRootDirectory(), lcse); + .warn(this, "Cannot restore state of cache for storage placed under " + writeCache.getRootDirectory(), lcsException); } catch (Exception e) { throw OException.wrapException( new OStorageException("Cannot restore state of cache for storage placed under " + writeCache.getRootDirectory()), e); @@ -791,8 +793,7 @@ private void restoreQueue(OWriteCache writeCache, LRUList queue, DataInputStream * @param queue Queue, state of which should be restored. * @param writeCache Write cache is used to load data from disk if needed. */ - private void restoreQueueWithoutPageLoad(OWriteCache writeCache, LRUList queue, DataInputStream dataInputStream) - throws IOException { + private void restoreQueueWithoutPageLoad(OWriteCache writeCache, LRUList queue, DataInputStream dataInputStream) { //this set is only needed to rollback changes in case of IO Exception final Set addedPages = new HashSet<>(); @@ -955,6 +956,7 @@ private void restoreQueueWithPageLoad(OWriteCache writeCache, LRUList queue, Dat * * @param writeCache Write cache which manages files cache state of which is going to be stored. */ + @Override public void storeCacheState(OWriteCache writeCache) { if (!OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE.getValueAsBoolean()) { return; @@ -1542,12 +1544,8 @@ public int compareTo(PinnedPage other) { if (fileId < other.fileId) return -1; - if (pageIndex > other.pageIndex) - return 1; - if (pageIndex < other.pageIndex) - return -1; + return Long.compare(pageIndex, other.pageIndex); - return 0; } } @@ -1584,12 +1582,8 @@ public int compareTo(PageKey other) { if (fileId < other.fileId) return -1; - if (pageIndex > other.pageIndex) - return 1; - if (pageIndex < other.pageIndex) - return -1; + return Long.compare(pageIndex, other.pageIndex); - return 0; } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCacheMXBean.java b/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCacheMXBean.java deleted file mode 100644 index d2da1074965..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/cache/local/twoq/O2QCacheMXBean.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.storage.cache.local.twoq; - -public interface O2QCacheMXBean { - int getA1InSize(); - - int getA1OutSize(); - - int getAmSize(); - - long getUsedMemory(); - - long getUsedMemoryInMB(); - - double getUsedMemoryInGB(); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFile.java b/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFile.java index e22a5110152..7733e378878 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFile.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFile.java @@ -31,62 +31,42 @@ public interface OFile { /** * Opens the file. - * - * @return - * - * @throws IOException */ void open(); /** * Creates the file. - * - * @throws IOException */ void create() throws IOException; /** * Closes the file. - * - * @throws IOException */ void close(); /** * Deletes the file. - * - * @throws IOException */ void delete() throws IOException; - boolean synch() throws IOException; + void synch(); void read(long iOffset, byte[] iDestBuffer, int iLength) throws IOException; - short readShort(long iLogicalPosition) throws IOException; - int readInt(long iLogicalPosition) throws IOException; long readLong(long iOffset) throws IOException; - byte readByte(long iOffset) throws IOException; - void writeInt(long iOffset, int iValue) throws IOException; void writeLong(long iOffset, long iValue) throws IOException; - void writeShort(long iOffset, short iValue) throws IOException; - void writeByte(long iOffset, byte iValue) throws IOException; void write(long iOffset, byte[] iSourceBuffer) throws IOException; /** * Shrink the file content (filledUpTo attribute only) - * - * @param iSize - * - * @throws IOException */ void shrink(final long iSize) throws IOException; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFileClassic.java b/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFileClassic.java index 5032ea0738f..a7cc1365064 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFileClassic.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/fs/OFileClassic.java @@ -114,6 +114,7 @@ public long getFileSize() { return size; } + @Override public void read(long offset, byte[] iData, int iLength, int iArrayOffset) throws IOException { int attempts = 0; @@ -238,6 +239,7 @@ public void write(long offset, ByteBuffer[] buffers) throws IOException { } } + @Override public void write(long iOffset, byte[] iData, int iSize, int iArrayOffset) throws IOException { int attempts = 0; @@ -315,50 +317,6 @@ public long readLong(long iOffset) throws IOException { } } - @Override - public short readShort(long iOffset) throws IOException { - int attempts = 0; - - while (true) { - try { - acquireReadLock(); - try { - iOffset = checkRegions(iOffset, OBinaryProtocol.SIZE_SHORT); - return readData(iOffset, OBinaryProtocol.SIZE_SHORT).getShort(); - } finally { - releaseReadLock(); - attempts++; - } - } catch (IOException e) { - OLogManager.instance() - .error(this, "Error during read of short data for file '" + getName() + "' " + attempts + "-th attempt", e); - reopenFile(attempts, e); - } - } - } - - @Override - public byte readByte(long iOffset) throws IOException { - int attempts = 0; - - while (true) { - try { - acquireReadLock(); - try { - iOffset = checkRegions(iOffset, OBinaryProtocol.SIZE_BYTE); - return readData(iOffset, OBinaryProtocol.SIZE_BYTE).get(); - } finally { - releaseReadLock(); - attempts++; - } - } catch (IOException e) { - OLogManager.instance() - .error(this, "Error during read of byte data for file '" + getName() + "' " + attempts + "-th attempt", e); - reopenFile(attempts, e); - } - } - } - @Override public void writeInt(long iOffset, final int iValue) throws IOException { int attempts = 0; @@ -413,32 +371,6 @@ public void writeLong(long iOffset, final long iValue) throws IOException { } } - @Override - public void writeShort(long iOffset, final short iValue) throws IOException { - int attempts = 0; - - while (true) { - try { - acquireWriteLock(); - try { - iOffset += HEADER_SIZE; - final ByteBuffer buffer = ByteBuffer.allocate(OBinaryProtocol.SIZE_SHORT); - buffer.putShort(iValue); - writeBuffer(buffer, iOffset); - setDirty(); - break; - } finally { - releaseWriteLock(); - attempts++; - } - } catch (IOException e) { - OLogManager.instance() - .error(this, "Error during write of short data for file '" + getName() + "' " + attempts + "-th attempt", e); - reopenFile(attempts, e); - } - } - } - @Override public void writeByte(long iOffset, final byte iValue) throws IOException { int attempts = 0; @@ -493,17 +425,16 @@ public void write(long iOffset, final byte[] iSourceBuffer) throws IOException { * Synchronizes the buffered changes to disk. */ @Override - public boolean synch() throws IOException { + public void synch() { acquireWriteLock(); try { flushHeader(); - return true; } finally { releaseWriteLock(); } } - private void flushHeader() throws IOException { + private void flushHeader() { acquireWriteLock(); try { if (headerDirty || dirty) { @@ -599,6 +530,7 @@ private long getSize() throws IOException { * * @see com.orientechnologies.orient.core.storage.fs.OFileAAA#open() */ + @Override public void open() { acquireWriteLock(); try { @@ -626,6 +558,7 @@ public void open() { * * @see com.orientechnologies.orient.core.storage.fs.OFileAAA#close() */ + @Override public void close() { int attempts = 0; @@ -661,6 +594,7 @@ public void close() { * * @see com.orientechnologies.orient.core.storage.fs.OFileAAA#delete() */ + @Override public void delete() throws IOException { int attempts = 0; @@ -735,6 +669,7 @@ private void init() throws IOException { * * @see com.orientechnologies.orient.core.storage.fs.OFileAAA#isOpen() */ + @Override public boolean isOpen() { acquireReadLock(); try { @@ -750,6 +685,7 @@ public boolean isOpen() { * * @see com.orientechnologies.orient.core.storage.fs.OFileAAA#exists() */ + @Override public boolean exists() { acquireReadLock(); try { @@ -779,6 +715,7 @@ private void setHeaderDirty() { } } + @Override public String getName() { acquireReadLock(); try { @@ -791,6 +728,7 @@ public String getName() { } } + @Override public String getPath() { acquireReadLock(); try { @@ -800,6 +738,7 @@ public String getPath() { } } + @Override public void renameTo(final Path newFile) throws IOException { acquireWriteLock(); try { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java index eb1910d1699..82037426732 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java @@ -114,6 +114,7 @@ public abstract class OAbstractPaginatedStorage extends OStorageAbstract private static final Comparator COMMIT_RECORD_OPERATION_COMPARATOR = Comparator .comparing(o -> o.getRecord().getIdentity()); + @SuppressWarnings("CanBeFinal") private static volatile DataOutputStream journaledStream = null; static { @@ -589,7 +590,7 @@ public boolean check(final boolean verbose, final OCommandOutputListener listene } @Override - public int addCluster(String clusterName, boolean forceListBased, final Object... parameters) { + public int addCluster(String clusterName, final Object... parameters) { try { checkOpenness(); checkLowDiskSpaceRequestsAndBackgroundDataFlushExceptionsAndBrokenPages(); @@ -616,7 +617,7 @@ public int addCluster(String clusterName, boolean forceListBased, final Object.. } @Override - public int addCluster(String clusterName, int requestedId, boolean forceListBased, Object... parameters) { + public int addCluster(String clusterName, int requestedId, Object... parameters) { try { checkOpenness(); checkLowDiskSpaceRequestsAndBackgroundDataFlushExceptionsAndBrokenPages(); @@ -3777,7 +3778,7 @@ protected void makeFuzzyCheckpoint() { } } - protected void makeFullCheckpoint() throws IOException { + protected void makeFullCheckpoint() { final OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic(); if (statistic != null) statistic.startFullCheckpointTimer(); @@ -3842,7 +3843,7 @@ protected void makeStorageDirty() throws IOException { protected void clearStorageDirty() throws IOException { } - protected boolean isDirty() throws IOException { + protected boolean isDirty() { return false; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OLowDiskSpaceInformation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OLowDiskSpaceInformation.java old mode 100644 new mode 100755 index 131a81b3cb3..fb3174d8fe4 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OLowDiskSpaceInformation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OLowDiskSpaceInformation.java @@ -5,8 +5,8 @@ * @since 05/02/15 */ public class OLowDiskSpaceInformation { -public long freeSpace; -public long requiredSpace; + public final long freeSpace; + public final long requiredSpace; public OLowDiskSpaceInformation(long freeSpace, long requiredSpace) { this.freeSpace = freeSpace; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OMicroTransaction.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OMicroTransaction.java old mode 100644 new mode 100755 index 15fd0d28192..a2b9a0744da --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OMicroTransaction.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OMicroTransaction.java @@ -468,7 +468,7 @@ private ORecordOperation addRecordOperation(ORecord record, byte type, String cl if (result == ORecordHook.RESULT.RECORD_CHANGED && record instanceof ODocument) ((ODocument) record).validate(); if (result == ORecordHook.RESULT.RECORD_CHANGED) - resave(record); + reSave(record); } break; @@ -478,7 +478,7 @@ private ORecordOperation addRecordOperation(ORecord record, byte type, String cl if (result == ORecordHook.RESULT.RECORD_CHANGED && record instanceof ODocument) ((ODocument) record).validate(); if (result == ORecordHook.RESULT.RECORD_CHANGED) - resave(record); + reSave(record); } break; @@ -602,7 +602,7 @@ public void addChangedDocument(ODocument document) { changedDocuments.add(document); } - private void resave(ORecord record) { + private void reSave(ORecord record) { final ODirtyManager manager = ORecordInternal.getDirtyManager(record); final Set newRecords = manager.getNewRecords(); final Set updatedRecords = manager.getUpdateRecords(); @@ -716,8 +716,8 @@ private enum Dependency { } private static class KeyChangesUpdateRecord { - public final OTransactionIndexChangesPerKey keyChanges; - public final OTransactionIndexChanges indexChanges; + final OTransactionIndexChangesPerKey keyChanges; + final OTransactionIndexChanges indexChanges; public KeyChangesUpdateRecord(OTransactionIndexChangesPerKey keyChanges, OTransactionIndexChanges indexChanges) { this.keyChanges = keyChanges; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OSingleFileSegment.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OSingleFileSegment.java index 01f1beee93b..85173b4e123 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OSingleFileSegment.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OSingleFileSegment.java @@ -28,23 +28,20 @@ import com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage; public class OSingleFileSegment { - protected OLocalPaginatedStorage storage; - protected OFile file; - protected OStorageFileConfiguration config; - private boolean wasSoftlyClosedAtPreviousTime = true; + private final OFile file; + private final OStorageFileConfiguration config; - public OSingleFileSegment(final OLocalPaginatedStorage iStorage, final OStorageFileConfiguration iConfig) throws IOException { + public OSingleFileSegment(final OLocalPaginatedStorage iStorage, final OStorageFileConfiguration iConfig) { this(iStorage, iConfig, iConfig.type); } public OSingleFileSegment(final OLocalPaginatedStorage iStorage, final OStorageFileConfiguration iConfig, final String iType) { config = iConfig; - storage = iStorage; - file = new OFileClassic(Paths.get(iStorage.getVariableParser().resolveVariables(iConfig.path))); + file = new OFileClassic(Paths.get(iStorage.getVariableParser().resolveVariables(iConfig.path))); } - public void open() throws IOException { + public void open() { file.open(); } @@ -52,7 +49,7 @@ public void create(final int iStartSize) throws IOException { file.create(); } - public void close() throws IOException { + public void close() { if (file != null) file.close(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageConfigurationSegment.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageConfigurationSegment.java index cda20092797..925ad8acecf 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageConfigurationSegment.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageConfigurationSegment.java @@ -50,7 +50,7 @@ public class OStorageConfigurationSegment extends OStorageConfiguration { private static final long ENCODING_FLAG_2 = 587138568122547L; private static final long ENCODING_FLAG_3 = 812587836547249L; - public OStorageConfigurationSegment(final OLocalPaginatedStorage iStorage) throws IOException { + public OStorageConfigurationSegment(final OLocalPaginatedStorage iStorage) { super(iStorage, Charset.forName("UTF-8")); segment = new OSingleFileSegment((OLocalPaginatedStorage) storage, diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageVariableParser.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageVariableParser.java old mode 100644 new mode 100755 index 73fe23f9019..fc0b333d18b --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageVariableParser.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OStorageVariableParser.java @@ -25,11 +25,10 @@ import java.nio.file.Path; public class OStorageVariableParser implements OVariableParserListener { - public static final String STORAGE_PATH = "STORAGE_PATH"; - private Path dbPath; - public static final String VAR_BEGIN = "${"; - public static final String VAR_END = "}"; - public static final String DB_PATH_VARIABLE = VAR_BEGIN + STORAGE_PATH + VAR_END; + private static final String STORAGE_PATH = "STORAGE_PATH"; + private final Path dbPath; + private static final String VAR_BEGIN = "${"; + private static final String VAR_END = "}"; public OStorageVariableParser(Path dbPath) { this.dbPath = dbPath; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPage.java index dce31ffc26b..6b0841053e6 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPage.java @@ -29,8 +29,6 @@ import com.orientechnologies.orient.core.storage.cache.OCacheEntry; import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurablePage; -import java.io.IOException; - /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) * @since 19.03.13 @@ -62,7 +60,7 @@ public class OClusterPage extends ODurablePage { private static final int ENTRY_KIND_UNKNOWN = 0; private static final int ENTRY_KIND_DATA = +1; - public OClusterPage(OCacheEntry cacheEntry, boolean newPage) throws IOException { + public OClusterPage(OCacheEntry cacheEntry, boolean newPage) { super(cacheEntry); if (newPage) { @@ -74,7 +72,7 @@ public OClusterPage(OCacheEntry cacheEntry, boolean newPage) throws IOException } } - public int appendRecord(final int recordVersion, final byte[] record) throws IOException { + public int appendRecord(final int recordVersion, final byte[] record) { int freePosition = getIntValue(FREE_POSITION_OFFSET); final int indexesLength = getIntValue(PAGE_INDEXES_LENGTH_OFFSET); @@ -146,7 +144,7 @@ public int appendRecord(final int recordVersion, final byte[] record) throws IOE return entryIndex; } - public int replaceRecord(int entryIndex, byte[] record, final int recordVersion) throws IOException { + public int replaceRecord(int entryIndex, byte[] record, final int recordVersion) { int entryIndexPosition = PAGE_INDEXES_OFFSET + entryIndex * INDEX_ITEM_SIZE; if (recordVersion != -1) { @@ -196,7 +194,7 @@ private boolean checkSpace(int entrySize, int freeListHeader) { return true; } - public boolean deleteRecord(int position) throws IOException { + public boolean deleteRecord(int position) { int indexesLength = getIntValue(PAGE_INDEXES_LENGTH_OFFSET); if (position >= indexesLength) return false; @@ -319,7 +317,7 @@ public long getNextPage() { return getLongValue(NEXT_PAGE_OFFSET); } - public void setNextPage(final long nextPage) throws IOException { + public void setNextPage(final long nextPage) { setLongValue(NEXT_PAGE_OFFSET, nextPage); } @@ -327,11 +325,11 @@ public long getPrevPage() { return getLongValue(PREV_PAGE_OFFSET); } - public void setPrevPage(final long prevPage) throws IOException { + public void setPrevPage(final long prevPage) { setLongValue(PREV_PAGE_OFFSET, prevPage); } - public void setRecordLongValue(final int recordPosition, final int offset, final long value) throws IOException { + public void setRecordLongValue(final int recordPosition, final int offset, final long value) { assert isPositionInsideInterval(recordPosition); final int entryIndexPosition = PAGE_INDEXES_OFFSET + recordPosition * INDEX_ITEM_SIZE; @@ -365,7 +363,7 @@ public long getRecordLongValue(final int recordPosition, final int offset) { } } - public byte[] getRecordBinaryValue(final int recordPosition, final int offset, final int size) throws IOException { + public byte[] getRecordBinaryValue(final int recordPosition, final int offset, final int size) { assert isPositionInsideInterval(recordPosition); final int entryIndexPosition = PAGE_INDEXES_OFFSET + recordPosition * INDEX_ITEM_SIZE; @@ -463,11 +461,11 @@ private boolean insideRecordBounds(final int entryPosition, final int offset, fi return offset >= 0 && offset + contentSize <= recordSize; } - private void incrementEntriesCount() throws IOException { + private void incrementEntriesCount() { setIntValue(ENTRIES_COUNT_OFFSET, getRecordsCount() + 1); } - private void decrementEntriesCount() throws IOException { + private void decrementEntriesCount() { setIntValue(ENTRIES_COUNT_OFFSET, getRecordsCount() - 1); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMap.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMap.java index 366735e0dcf..484a44f2b06 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMap.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMap.java @@ -83,7 +83,7 @@ public void create() throws IOException { } } - public void flush() throws IOException { + public void flush() { startOperation(); try { atomicOperationsManager.acquireReadLock(this); @@ -305,11 +305,7 @@ public void update(final long clusterPosition, final OClusterPositionMapBucket.P } endAtomicOperation(false, null); - } catch (IOException e) { - endAtomicOperation(true, e); - throw OException.wrapException( - new OClusterPositionMapException("Error of update of mapping between logical adn physical record position", this), e); - } catch (RuntimeException e) { + } catch (IOException | RuntimeException e) { endAtomicOperation(true, e); throw OException.wrapException( new OClusterPositionMapException("Error of update of mapping between logical adn physical record position", this), e); @@ -344,12 +340,7 @@ public void resurrect(final long clusterPosition, final OClusterPositionMapBucke } endAtomicOperation(false, null); - } catch (IOException e) { - endAtomicOperation(true, e); - throw OException.wrapException( - new OClusterPositionMapException("Error of resurrecting mapping between logical adn physical record position", this), - e); - } catch (RuntimeException e) { + } catch (IOException | RuntimeException e) { endAtomicOperation(true, e); throw OException.wrapException( new OClusterPositionMapException("Error of resurrecting mapping between logical adn physical record position", this), @@ -395,7 +386,7 @@ public OClusterPositionMapBucket.PositionEntry get(final long clusterPosition, f } } - public OClusterPositionMapBucket.PositionEntry remove(final long clusterPosition) throws IOException { + public void remove(final long clusterPosition) throws IOException { startOperation(); try { OAtomicOperation atomicOperation = startAtomicOperation(true); @@ -410,7 +401,7 @@ public OClusterPositionMapBucket.PositionEntry remove(final long clusterPosition try { final OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry); - return bucket.remove(index); + bucket.remove(index); } catch (Exception e) { exception = e; throw OException.wrapException( @@ -737,18 +728,15 @@ public long getNextPosition() throws IOException { OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation(); final long filledUpTo = getFilledUpTo(atomicOperation, fileId); - for (long pageIndex = filledUpTo - 1; pageIndex >= 0; pageIndex--) { - OCacheEntry cacheEntry = loadPageForRead(atomicOperation, fileId, pageIndex, false, 1); - try { - OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry); - final int bucketSize = bucket.getSize(); - return pageIndex * OClusterPositionMapBucket.MAX_ENTRIES + bucketSize; - } finally { - releasePageFromRead(atomicOperation, cacheEntry); - } + final long pageIndex = filledUpTo - 1; + OCacheEntry cacheEntry = loadPageForRead(atomicOperation, fileId, pageIndex, false, 1); + try { + OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry); + final int bucketSize = bucket.getSize(); + return pageIndex * OClusterPositionMapBucket.MAX_ENTRIES + bucketSize; + } finally { + releasePageFromRead(atomicOperation, cacheEntry); } - - return ORID.CLUSTER_POS_INVALID; } finally { releaseSharedLock(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMapBucket.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMapBucket.java index 526e6bbbbe1..e6802334559 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMapBucket.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OClusterPositionMapBucket.java @@ -27,8 +27,6 @@ import com.orientechnologies.orient.core.storage.cache.OCacheEntry; import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurablePage; -import java.io.IOException; - /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) * @since 10/7/13 @@ -44,7 +42,7 @@ public class OClusterPositionMapBucket extends ODurablePage { public static final byte FILLED = 2; public static final byte ALLOCATED = 4; - public static final int ENTRY_SIZE = OByteSerializer.BYTE_SIZE + OIntegerSerializer.INT_SIZE + OLongSerializer.LONG_SIZE; + private static final int ENTRY_SIZE = OByteSerializer.BYTE_SIZE + OIntegerSerializer.INT_SIZE + OLongSerializer.LONG_SIZE; public static final int MAX_ENTRIES = (MAX_PAGE_SIZE_BYTES - POSITIONS_OFFSET) / ENTRY_SIZE; @@ -52,7 +50,7 @@ public OClusterPositionMapBucket(OCacheEntry cacheEntry) { super(cacheEntry); } - public int add(long pageIndex, int recordPosition) throws IOException { + public int add(long pageIndex, int recordPosition) { int size = getIntValue(SIZE_OFFSET); int position = entryPosition(size); @@ -66,7 +64,7 @@ public int add(long pageIndex, int recordPosition) throws IOException { return size; } - public int allocate() throws IOException { + public int allocate() { int size = getIntValue(SIZE_OFFSET); int position = entryPosition(size); @@ -93,7 +91,7 @@ public PositionEntry get(int index) { return readEntry(position); } - public void set(final int index, final PositionEntry entry) throws IOException { + public void set(final int index, final PositionEntry entry) { final int size = getIntValue(SIZE_OFFSET); if (index >= size) @@ -109,7 +107,7 @@ else if (flag != FILLED) updateEntry(position, entry); } - public void resurrect(final int index, final PositionEntry entry) throws IOException { + public void resurrect(final int index, final PositionEntry entry) { final int size = getIntValue(SIZE_OFFSET); if (index >= size) @@ -137,20 +135,20 @@ public int getSize() { return getIntValue(SIZE_OFFSET); } - public PositionEntry remove(int index) { + public void remove(int index) { int size = getIntValue(SIZE_OFFSET); if (index >= size) - return null; + return; int position = entryPosition(index); if (getByteValue(position) != FILLED) - return null; + return; setByteValue(position, REMOVED); - return readEntry(position); + readEntry(position); } private PositionEntry readEntry(int position) { @@ -164,7 +162,7 @@ private PositionEntry readEntry(int position) { return new PositionEntry(pageIndex, pagePosition); } - private void updateEntry(int position, final PositionEntry entry) throws IOException { + private void updateEntry(int position, final PositionEntry entry) { position += OByteSerializer.BYTE_SIZE; setLongValue(position, entry.pageIndex); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OLocalPaginatedStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OLocalPaginatedStorage.java index 54b9f0a631a..1009e892c19 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OLocalPaginatedStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OLocalPaginatedStorage.java @@ -463,7 +463,7 @@ protected void clearStorageDirty() throws IOException { } @Override - protected boolean isDirty() throws IOException { + protected boolean isDirty() { return dirtyFlag.isDirty(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineCluster.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineCluster.java old mode 100644 new mode 100755 index 389c27d2f5f..f7787bdded7 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineCluster.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineCluster.java @@ -37,8 +37,8 @@ public class OOfflineCluster implements OCluster { private final String name; - private int id; - private OAbstractPaginatedStorage storageLocal; + private final int id; + private final OAbstractPaginatedStorage storageLocal; public OOfflineCluster(final OAbstractPaginatedStorage iStorage, final int iId, final String iName) { storageLocal = iStorage; @@ -113,7 +113,7 @@ public void truncate() throws IOException { @Override public OPhysicalPosition allocatePosition(byte recordType) throws IOException { - throw new OOfflineClusterException("Cannot allocat a new position on offline cluster '" + name + "'"); + throw new OOfflineClusterException("Cannot allocate a new position on offline cluster '" + name + "'"); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineClusterException.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineClusterException.java index ac8206fda99..f8177a83b42 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineClusterException.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OOfflineClusterException.java @@ -15,7 +15,6 @@ */ package com.orientechnologies.orient.core.storage.impl.local.paginated; -import com.orientechnologies.common.exception.OHighLevelException; import com.orientechnologies.orient.core.exception.OCoreException; /** diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java index 35b1e335524..d7730370d9f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedCluster.java @@ -152,6 +152,7 @@ public void configure(final OStorage storage, final OStorageClusterConfiguration } } + @Override public boolean exists() { startOperation(); try { @@ -288,6 +289,7 @@ public void close() throws IOException { close(true); } + @Override public void close(final boolean flush) throws IOException { startOperation(); try { @@ -443,10 +445,7 @@ public OPhysicalPosition allocatePosition(byte recordType) throws IOException { final OPhysicalPosition pos = createPhysicalPosition(recordType, clusterPositionMap.allocate(), -1); endAtomicOperation(false, null); return pos; - } catch (IOException e) { - endAtomicOperation(true, e); - throw e; - } catch (RuntimeException e) { + } catch (IOException | RuntimeException e) { endAtomicOperation(true, e); throw e; } finally { @@ -457,8 +456,8 @@ public OPhysicalPosition allocatePosition(byte recordType) throws IOException { } } - public OPhysicalPosition createRecord(byte[] content, final int recordVersion, final byte recordType, - OPhysicalPosition allocatedPosition) throws IOException { + @Override + public OPhysicalPosition createRecord(byte[] content, final int recordVersion, final byte recordType, OPhysicalPosition allocatedPosition) throws IOException { startOperation(); OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic(); if (statistic != null) @@ -497,8 +496,7 @@ public OPhysicalPosition createRecord(byte[] content, final int recordVersion, f final long clusterPosition; if (allocatedPosition != null) { - clusterPositionMap.update(allocatedPosition.clusterPosition, - new OClusterPositionMapBucket.PositionEntry(addEntryResult.pageIndex, addEntryResult.pagePosition)); + clusterPositionMap.update(allocatedPosition.clusterPosition, new OClusterPositionMapBucket.PositionEntry(addEntryResult.pageIndex, addEntryResult.pagePosition)); clusterPosition = allocatedPosition.clusterPosition; } else clusterPosition = clusterPositionMap.add(addEntryResult.pageIndex, addEntryResult.pagePosition); @@ -583,8 +581,7 @@ public OPhysicalPosition createRecord(byte[] content, final int recordVersion, f updateClusterState(1, recordsSizeDiff, atomicOperation); final long clusterPosition; if (allocatedPosition != null) { - clusterPositionMap.update(allocatedPosition.clusterPosition, - new OClusterPositionMapBucket.PositionEntry(firstPageIndex, firstPagePosition)); + clusterPositionMap.update(allocatedPosition.clusterPosition, new OClusterPositionMapBucket.PositionEntry(firstPageIndex, firstPagePosition)); clusterPosition = allocatedPosition.clusterPosition; } else clusterPosition = clusterPositionMap.add(firstPageIndex, firstPagePosition); @@ -634,6 +631,7 @@ private static int getEntryContentLength(int grownContentSize) { return entryContentLength; } + @Override @SuppressFBWarnings(value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS") public ORawBuffer readRecord(final long clusterPosition, boolean prefetchRecords) throws IOException { int pagesToPrefetch = 1; @@ -666,7 +664,7 @@ private ORawBuffer readRecord(final long clusterPosition, final int pageCount) t if (getFilledUpTo(atomicOperation, fileId) <= pageIndex) return null; - int recordVersion = 0; + int recordVersion; final OCacheEntry cacheEntry = loadPageForRead(atomicOperation, fileId, pageIndex, false, pageCount); try { final OClusterPage localPage = new OClusterPage(cacheEntry, false); @@ -733,7 +731,7 @@ public ORawBuffer readRecordIfVersionIsNotLatest(long clusterPosition, final int throw new ORecordNotFoundException(new ORecordId(id, clusterPosition), "Record for cluster with id " + id + " and position " + clusterPosition + " is absent."); - int loadedRecordVersion = 0; + int loadedRecordVersion; OCacheEntry cacheEntry = loadPageForRead(atomicOperation, fileId, pageIndex, false); try { @@ -762,6 +760,7 @@ public ORawBuffer readRecordIfVersionIsNotLatest(long clusterPosition, final int } } + @Override public boolean deleteRecord(long clusterPosition) throws IOException { startOperation(); OSessionStoragePerformanceStatistic statistic = performanceStatisticManager.getSessionPerformanceStatistic(); @@ -807,8 +806,7 @@ public boolean deleteRecord(long clusterPosition) throws IOException { } return false; } else - throw new OPaginatedClusterException("Content of record " + new ORecordId(id, clusterPosition) + " was broken", - this); + throw new OPaginatedClusterException("Content of record " + new ORecordId(id, clusterPosition) + " was broken", this); } else if (removedContentSize == 0) { releasePageFromWrite(atomicOperation, cacheEntry); @@ -843,10 +841,7 @@ public boolean deleteRecord(long clusterPosition) throws IOException { endAtomicOperation(false, null); return true; - } catch (IOException e) { - endAtomicOperation(true, e); - throw OException.wrapException(new OPaginatedClusterException("Error during record deletion", this), e); - } catch (RuntimeException e) { + } catch (IOException | RuntimeException e) { endAtomicOperation(true, e); throw OException.wrapException(new OPaginatedClusterException("Error during record deletion", this), e); } finally { @@ -900,6 +895,7 @@ public boolean hideRecord(long position) throws IOException { } } + @Override public void updateRecord(final long clusterPosition, byte[] content, final int recordVersion, final byte recordType) throws IOException { startOperation(); @@ -946,8 +942,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r entrySize = Math.min(getEntryContentLength(content.length), OClusterPage.MAX_RECORD_SIZE); to = entrySize - (2 * OByteSerializer.BYTE_SIZE + OIntegerSerializer.INT_SIZE + OLongSerializer.LONG_SIZE); } else { - entrySize = Math - .min(content.length - from + OByteSerializer.BYTE_SIZE + OLongSerializer.LONG_SIZE, OClusterPage.MAX_RECORD_SIZE); + entrySize = Math.min(content.length - from + OByteSerializer.BYTE_SIZE + OLongSerializer.LONG_SIZE, OClusterPage.MAX_RECORD_SIZE); to = from + entrySize - (OByteSerializer.BYTE_SIZE + OLongSerializer.LONG_SIZE); } @@ -997,7 +992,6 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r OCacheEntry cacheEntry = loadPageForWrite(atomicOperation, fileId, nextPageIndex, false); if (cacheEntry == null) { cacheEntry = addPage(atomicOperation, fileId); - nextPageIndex = cacheEntry.getPageIndex(); isNew = true; } @@ -1012,8 +1006,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r if (nextRecordPosition >= 0) { if (localPage.isDeleted(nextRecordPosition)) - throw new OPaginatedClusterException("Record with rid " + new ORecordId(id, clusterPosition) + " was deleted", - this); + throw new OPaginatedClusterException("Record with rid " + new ORecordId(id, clusterPosition) + " was deleted", this); int currentEntrySize = localPage.getRecordSize(nextRecordPosition); nextEntryPointer = localPage.getRecordLongValue(nextRecordPosition, currentEntrySize - OLongSerializer.LONG_SIZE); @@ -1029,8 +1022,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r if (updatedEntryPosition < 0) { localPage.dumpToLog(); - throw new IllegalStateException("Page " + cacheEntry.getPageIndex() - + " does not have enough free space to add record content, freePageIndex=" + freePageIndex + throw new IllegalStateException("Page " + cacheEntry.getPageIndex() + " does not have enough free space to add record content, freePageIndex=" + freePageIndex + ", updateEntry.length=" + updateEntry.length + ", content.length=" + content.length); } } else { @@ -1053,8 +1045,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r if (updatedEntryPosition < 0) { localPage.dumpToLog(); throw new IllegalStateException( - "Page " + cacheEntry.getPageIndex() + " does not have enough free space to add record content, freePageIndex=" - + freePageIndex + ", updateEntry.length=" + updateEntry.length + ", content.length=" + content.length); + "Page " + cacheEntry.getPageIndex() + " does not have enough free space to add record content, freePageIndex=" + freePageIndex + ", updateEntry.length=" + updateEntry.length + ", content.length=" + content.length); } nextPageIndex = -1; @@ -1081,8 +1072,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r OCacheEntry prevCacheEntry = loadPageForWrite(atomicOperation, fileId, prevPageIndex, false); try { OClusterPage prevPage = new OClusterPage(prevCacheEntry, false); - prevPage.setRecordLongValue(prevRecordPosition, -OLongSerializer.LONG_SIZE, - createPagePointer(cacheEntry.getPageIndex(), updatedEntryPosition)); + prevPage.setRecordLongValue(prevRecordPosition, -OLongSerializer.LONG_SIZE, createPagePointer(cacheEntry.getPageIndex(), updatedEntryPosition)); } finally { releasePageFromWrite(atomicOperation, prevCacheEntry); } @@ -1148,6 +1138,7 @@ public void updateRecord(final long clusterPosition, byte[] content, final int r /** * Recycles a deleted record. */ + @Override public void recycleRecord(final long clusterPosition, byte[] content, final int recordVersion, final byte recordType) throws IOException { startOperation(); @@ -1222,8 +1213,6 @@ public void recycleRecord(final long clusterPosition, byte[] content, final int long firstPageIndex = -1; int firstPagePosition = -1; - int version = 0; - int from = 0; int to = from + (OClusterPage.MAX_RECORD_SIZE - OByteSerializer.BYTE_SIZE - OLongSerializer.LONG_SIZE); @@ -1246,7 +1235,6 @@ public void recycleRecord(final long clusterPosition, byte[] content, final int if (firstPageIndex == -1) { firstPageIndex = addEntryResult.pageIndex; firstPagePosition = addEntryResult.pagePosition; - version = addEntryResult.recordVersion; } long addedPagePointer = createPagePointer(addEntryResult.pageIndex, addEntryResult.pagePosition); @@ -1664,6 +1652,7 @@ public OPhysicalPosition[] floorPositions(OPhysicalPosition position) throws IOE } } + @Override public ORecordConflictStrategy getRecordConflictStrategy() { return recordConflictStrategy; } @@ -1771,7 +1760,7 @@ private byte[] readFullEntry(final long clusterPosition, long pageIndex, int rec if (getFilledUpTo(atomicOperation, fileId) <= pageIndex) return null; - final List recordChunks = new ArrayList(); + final List recordChunks = new ArrayList<>(); int contentSize = 0; long nextPagePointer; @@ -2104,7 +2093,7 @@ public OPaginatedClusterDebug readDebug(long clusterPosition) throws IOException return debug; } - debug.pages = new ArrayList(); + debug.pages = new ArrayList<>(); int contentSize = 0; long nextPagePointer; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedClusterState.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedClusterState.java index 51f272d9fa9..d4bb636b8bc 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedClusterState.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedClusterState.java @@ -24,8 +24,6 @@ import com.orientechnologies.orient.core.storage.cache.OCacheEntry; import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurablePage; -import java.io.IOException; - /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) * @since 20.08.13 @@ -39,7 +37,7 @@ public OPaginatedClusterState(OCacheEntry cacheEntry) { super(cacheEntry); } - public void setSize(long size) throws IOException { + public void setSize(long size) { setLongValue(SIZE_OFFSET, size); } @@ -47,7 +45,7 @@ public long getSize() { return getLongValue(SIZE_OFFSET); } - public void setRecordsSize(long recordsSize) throws IOException { + public void setRecordsSize(long recordsSize) { setLongValue(RECORDS_SIZE_OFFSET, recordsSize); } @@ -55,7 +53,7 @@ public long getRecordsSize() { return getLongValue(RECORDS_SIZE_OFFSET); } - public void setFreeListPage(int index, long pageIndex) throws IOException { + public void setFreeListPage(int index, long pageIndex) { setLongValue(FREE_LIST_OFFSET + index * OLongSerializer.LONG_SIZE, pageIndex); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedStorageDirtyFlag.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedStorageDirtyFlag.java old mode 100644 new mode 100755 index bfae8a2a93a..74383df50ce --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedStorageDirtyFlag.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/OPaginatedStorageDirtyFlag.java @@ -41,9 +41,9 @@ * @since 5/6/14 */ public class OPaginatedStorageDirtyFlag { - private Path dirtyFilePath; - private FileChannel channel; - private FileLock fileLock; + private final Path dirtyFilePath; + private FileChannel channel; + private FileLock fileLock; private volatile boolean dirtyFlag; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordOperationMetadata.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordOperationMetadata.java old mode 100644 new mode 100755 index 2505636d612..8fcd86b225d --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordOperationMetadata.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordOperationMetadata.java @@ -35,7 +35,7 @@ public class ORecordOperationMetadata implements OAtomicOperationMetadata> { public static final String RID_METADATA_KEY = "cluster.record.rid"; - private final Set rids = new HashSet(); + private final Set rids = new HashSet<>(); public void addRid(ORID rid) { rids.add(rid); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java index 4106afb9b0e..2533bb39f77 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java @@ -21,8 +21,6 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated; import com.orientechnologies.orient.core.OOrientListenerAbstract; -import com.orientechnologies.orient.core.OOrientShutdownListener; -import com.orientechnologies.orient.core.OOrientStartupListener; import com.orientechnologies.orient.core.Orient; import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage; @@ -51,7 +49,8 @@ public void onShutdown() { } }); } - private final Deque operations = new ArrayDeque(); + + private final Deque operations = new ArrayDeque<>(); public static int getDepth() { return ORecordSerializationContext.SERIALIZATION_CONTEXT_STACK.get().size(); @@ -94,7 +93,7 @@ public void executeOperations(OAbstractPaginatedStorage storage) { private static class SerializationContextThreadLocal extends ThreadLocal> { @Override protected Deque initialValue() { - return new ArrayDeque(); + return new ArrayDeque<>(); } } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationOperation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationOperation.java old mode 100644 new mode 100755 index 17eb941bc74..63a6cf58d9f --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationOperation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationOperation.java @@ -20,7 +20,6 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated; -import com.orientechnologies.orient.core.storage.OAutoshardedStorage; import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage; /** diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperation.java index 81e1ee06506..55356ddf490 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperation.java @@ -19,7 +19,6 @@ */ package com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations; -import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.exception.OStorageException; import com.orientechnologies.orient.core.storage.cache.*; import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurablePage; @@ -37,7 +36,6 @@ * @since 12/3/13 */ public class OAtomicOperation { - private static final int PAGE_CACHE_SIZE = OGlobalConfiguration.TX_PAGE_CACHE_SIZE.getValueAsInteger(); private final int storageId; private final OLogSequenceNumber startLSN; @@ -47,18 +45,18 @@ public class OAtomicOperation { private boolean rollback; private Exception rollbackException; - private Set lockedObjects = new HashSet(); - private Map fileChanges = new HashMap(); - private Map newFileNamesId = new HashMap(); - private Set deletedFiles = new HashSet(); - private Map deletedFileNameIdMap = new HashMap(); + private final Set lockedObjects = new HashSet<>(); + private final Map fileChanges = new HashMap<>(); + private final Map newFileNamesId = new HashMap<>(); + private final Set deletedFiles = new HashSet<>(); + private final Map deletedFileNameIdMap = new HashMap<>(); - private OReadCache readCache; - private OWriteCache writeCache; + private final OReadCache readCache; + private final OWriteCache writeCache; private final OPerformanceStatisticManager performanceStatisticManager; - private final Map> metadata = new LinkedHashMap>(); + private final Map> metadata = new LinkedHashMap<>(); public OAtomicOperation(OLogSequenceNumber startLSN, OOperationUnitId operationUnitId, OReadCache readCache, OWriteCache writeCache, int storageId, OPerformanceStatisticManager performanceStatisticManager) { @@ -82,17 +80,12 @@ public OOperationUnitId getOperationUnitId() { public OCacheEntry loadPage(long fileId, long pageIndex, boolean checkPinnedPages, final int pageCount) throws IOException { assert pageCount > 0; - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); if (deletedFiles.contains(fileId)) throw new OStorageException("File with id " + fileId + " is deleted."); - FileChanges changesContainer = fileChanges.get(fileId); - - if (changesContainer == null) { - changesContainer = new FileChanges(); - fileChanges.put(fileId, changesContainer); - } + FileChanges changesContainer = fileChanges.computeIfAbsent(fileId, k -> new FileChanges()); if (changesContainer.isNew) { if (pageIndex <= changesContainer.maxNewPageIndex) { @@ -156,7 +149,7 @@ public Map> getMetadata() { return Collections.unmodifiableMap(metadata); } - public void pinPage(OCacheEntry cacheEntry) throws IOException { + public void pinPage(OCacheEntry cacheEntry) { if (deletedFiles.contains(cacheEntry.getFileId())) throw new OStorageException("File with id " + cacheEntry.getFileId() + " is deleted."); @@ -170,7 +163,7 @@ public void pinPage(OCacheEntry cacheEntry) throws IOException { } public OCacheEntry addPage(long fileId) throws IOException { - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); if (deletedFiles.contains(fileId)) throw new OStorageException("File with id " + fileId + " is deleted."); @@ -206,7 +199,7 @@ public void releasePage(OCacheEntry cacheEntry) { } public long filledUpTo(long fileId) throws IOException { - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); if (deletedFiles.contains(fileId)) throw new OStorageException("File with id " + fileId + " is deleted."); @@ -216,7 +209,7 @@ public long filledUpTo(long fileId) throws IOException { return internalFilledUpTo(fileId, changesContainer); } - private long internalFilledUpTo(long fileId, FileChanges changesContainer) throws IOException { + private long internalFilledUpTo(long fileId, FileChanges changesContainer) { if (changesContainer == null) { changesContainer = new FileChanges(); fileChanges.put(fileId, changesContainer); @@ -228,7 +221,7 @@ private long internalFilledUpTo(long fileId, FileChanges changesContainer) throw return writeCache.getFilledUpTo(fileId); } - public long addFile(String fileName) throws IOException { + public long addFile(String fileName) { if (newFileNamesId.containsKey(fileName)) throw new OStorageException("File with name " + fileName + " already exists."); @@ -263,17 +256,13 @@ public long loadFile(String fileName) throws IOException { if (fileId == null) fileId = writeCache.loadFile(fileName); - FileChanges fileChanges = this.fileChanges.get(fileId); - if (fileChanges == null) { - fileChanges = new FileChanges(); - this.fileChanges.put(fileId, fileChanges); - } + this.fileChanges.computeIfAbsent(fileId, k -> new FileChanges()); return fileId; } public void deleteFile(long fileId) { - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); final FileChanges fileChanges = this.fileChanges.remove(fileId); if (fileChanges != null && fileChanges.fileName != null) @@ -297,7 +286,7 @@ public boolean isFileExists(String fileName) { } public boolean isFileExists(long fileId) { - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); if (fileChanges.containsKey(fileId)) return true; @@ -309,7 +298,7 @@ public boolean isFileExists(long fileId) { } public String fileNameById(long fileId) { - fileId = checkFileIdCompatibilty(fileId, storageId); + fileId = checkFileIdCompatibility(fileId, storageId); FileChanges fileChanges = this.fileChanges.get(fileId); @@ -323,14 +312,9 @@ public String fileNameById(long fileId) { } public void truncateFile(long fileId) { - fileId = checkFileIdCompatibilty(fileId, storageId); - - FileChanges fileChanges = this.fileChanges.get(fileId); + fileId = checkFileIdCompatibility(fileId, storageId); - if (fileChanges == null) { - fileChanges = new FileChanges(); - this.fileChanges.put(fileId, fileChanges); - } + FileChanges fileChanges = this.fileChanges.computeIfAbsent(fileId, k -> new FileChanges()); fileChanges.pageChangesMap.clear(); fileChanges.maxNewPageIndex = -1; @@ -368,7 +352,7 @@ else if (fileChanges.truncate) Iterator> filePageChangesIterator = fileChanges.pageChangesMap.entrySet().iterator(); while (filePageChangesIterator.hasNext()) { Map.Entry filePageChangesEntry = filePageChangesIterator.next(); - //I assume new pages have everytime changes + //I assume new pages have always changes if (filePageChangesEntry.getValue().changes.hasChanges()) { final long pageIndex = filePageChangesEntry.getKey(); final OCacheEntryChanges filePageChanges = filePageChangesEntry.getValue(); @@ -438,9 +422,8 @@ void incrementCounter() { startCounter++; } - int decrementCounter() { + void decrementCounter() { startCounter--; - return startCounter; } int getCounter() { @@ -493,11 +476,11 @@ public int hashCode() { } private static class FileChanges { - private Map pageChangesMap = new HashMap(); - private long maxNewPageIndex = -2; - private boolean isNew = false; - private boolean truncate = false; - private String fileName = null; + private final Map pageChangesMap = new HashMap<>(); + private long maxNewPageIndex = -2; + private boolean isNew = false; + private boolean truncate = false; + private String fileName = null; } private int storageId(long fileId) { @@ -508,7 +491,7 @@ private long composeFileId(long fileId, int storageId) { return (((long) storageId) << 32) | fileId; } - private long checkFileIdCompatibilty(long fileId, int storageId) { + private long checkFileIdCompatibility(long fileId, int storageId) { // indicates that storage has no it's own id. if (storageId == -1) return fileId; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationMetadata.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationMetadata.java old mode 100644 new mode 100755 index 423a9c14a9c..69e667add8b --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationMetadata.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationMetadata.java @@ -22,6 +22,7 @@ * * @param Type of atomic operation metadata. */ +@SuppressWarnings("SameReturnValue") public interface OAtomicOperationMetadata extends Serializable { /** * @return Key associated with given metadata diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsManager.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsManager.java index 9658ceb6121..cd5d9512a37 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsManager.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsManager.java @@ -61,7 +61,8 @@ * @since 12/3/13 */ public class OAtomicOperationsManager implements OAtomicOperationsMangerMXBean { - public static final String MBEAN_NAME = "com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations:type=OAtomicOperationsMangerMXBean"; + @SuppressWarnings("SpellCheckingInspection") + private static final String MBEAN_NAME = "com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations:type=OAtomicOperationsMangerMXBean"; private volatile boolean trackAtomicOperations = OGlobalConfiguration.TX_TRACK_ATOMIC_OPERATIONS.getValueAsBoolean(); @@ -131,7 +132,7 @@ public OAtomicOperation startAtomicOperation(ODurableComponent durableComponent, * operation. *

*

In current implementation of atomic operation, each component which is participated in atomic operation is hold under - * exclusive lock till atomic operation will not be completed (committed or rollbacked). + * exclusive lock till atomic operation will not be completed (committed or rolled back). *

*

If other thread is going to read data from component it has to acquire read lock inside of atomic operation manager {@link * #acquireReadLock(ODurableComponent)}, otherwise data consistency will be compromised. diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsMangerMXBean.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsMangerMXBean.java index a42ad61106b..36451bc3e76 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsMangerMXBean.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsMangerMXBean.java @@ -1,8 +1,5 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations; -/** - * Created by lomak_000 on 7/17/2015. - */ public interface OAtomicOperationsMangerMXBean { void trackAtomicOperations(); void doNotTrackAtomicOperations(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OCacheEntryChanges.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OCacheEntryChanges.java old mode 100644 new mode 100755 index c3caa9968ef..dc24183f981 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OCacheEntryChanges.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OCacheEntryChanges.java @@ -11,11 +11,11 @@ */ public class OCacheEntryChanges implements OCacheEntry { - protected OCacheEntry delegate; - protected OWALChanges changes = new OWALPageChangesPortion(); - protected OLogSequenceNumber lsn = null; - protected boolean isNew = false; - protected boolean pinPage = false; + OCacheEntry delegate; + final OWALChanges changes = new OWALPageChangesPortion(); + OLogSequenceNumber lsn = null; + boolean isNew = false; + boolean pinPage = false; public OCacheEntryChanges(OCacheEntry entry) { delegate = entry; @@ -104,6 +104,7 @@ public void decrementUsages() { delegate.decrementUsages(); } + @Override public OWALChanges getChanges() { return changes; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/base/ODurableComponent.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/base/ODurableComponent.java index 97d723239c4..a172a8cc169 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/base/ODurableComponent.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/base/ODurableComponent.java @@ -66,7 +66,7 @@ public abstract class ODurableComponent extends OSharedResourceAdaptive { private volatile String name; private volatile String fullName; - protected final String extension; + private final String extension; private volatile String lockName; @@ -106,17 +106,12 @@ public String getExtension() { return extension; } - @Override - protected void acquireExclusiveLock() { - super.acquireExclusiveLock(); - } - protected void endAtomicOperation(boolean rollback, Exception e) throws IOException { atomicOperationsManager.endAtomicOperation(rollback, e); } /** - * @see OAtomicOperationsManager#startAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurableComponent, * boolean) + * @see OAtomicOperationsManager#startAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurableComponent, boolean) */ protected OAtomicOperation startAtomicOperation(boolean trackNonTxOperations) throws IOException { return atomicOperationsManager.startAtomicOperation(this, trackNonTxOperations); @@ -155,7 +150,7 @@ protected OCacheEntry loadPageForRead(OAtomicOperation atomicOperation, long fil return atomicOperation.loadPage(fileId, pageIndex, checkPinnedPages, pageCount); } - protected void pinPage(OAtomicOperation atomicOperation, OCacheEntry cacheEntry) throws IOException { + protected void pinPage(OAtomicOperation atomicOperation, OCacheEntry cacheEntry) { if (atomicOperation == null) readCache.pinPage(cacheEntry); else diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWALRecord.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWALRecord.java index 9c40e3f284b..943a1479b64 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWALRecord.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWALRecord.java @@ -36,10 +36,12 @@ protected OAbstractWALRecord(final OLogSequenceNumber previousCheckpoint) { this.lsn = previousCheckpoint; } + @Override public OLogSequenceNumber getLsn() { return lsn; } + @Override public void setLsn(final OLogSequenceNumber lsn) { this.lsn = lsn; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWriteAheadLog.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWriteAheadLog.java old mode 100644 new mode 100755 index 6d8464ec546..55462d1dee9 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWriteAheadLog.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAbstractWriteAheadLog.java @@ -23,7 +23,6 @@ import com.orientechnologies.orient.core.exception.OStorageException; import java.io.IOException; -import java.util.Set; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -32,11 +31,12 @@ * @since 6/25/14 */ public abstract class OAbstractWriteAheadLog implements OWriteAheadLog { - protected boolean closed; + boolean closed; - protected final Lock syncObject = new ReentrantLock(); - protected OLogSequenceNumber lastCheckpoint; + final Lock syncObject = new ReentrantLock(); + OLogSequenceNumber lastCheckpoint; + @Override public OLogSequenceNumber logFuzzyCheckPointStart(OLogSequenceNumber flushedLsn) throws IOException { syncObject.lock(); try { @@ -50,6 +50,7 @@ public OLogSequenceNumber logFuzzyCheckPointStart(OLogSequenceNumber flushedLsn) } } + @Override public OLogSequenceNumber logFuzzyCheckPointEnd() throws IOException { syncObject.lock(); try { @@ -63,10 +64,12 @@ public OLogSequenceNumber logFuzzyCheckPointEnd() throws IOException { } } + @Override public OLogSequenceNumber logFullCheckpointStart() throws IOException { return log(new OFullCheckpointStartRecord(lastCheckpoint)); } + @Override public OLogSequenceNumber logFullCheckpointEnd() throws IOException { syncObject.lock(); try { @@ -78,6 +81,7 @@ public OLogSequenceNumber logFullCheckpointEnd() throws IOException { } } + @Override public OLogSequenceNumber getLastCheckpoint() { syncObject.lock(); try { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAtomicUnitEndRecord.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAtomicUnitEndRecord.java index f84e1f2e33f..07fde6f51b7 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAtomicUnitEndRecord.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OAtomicUnitEndRecord.java @@ -20,9 +20,7 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; -import java.io.IOException; import java.util.Collections; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; @@ -42,13 +40,13 @@ public class OAtomicUnitEndRecord extends OOperationUnitBodyRecord { private boolean rollback; - private Map> atomicOperationMetadataMap = new LinkedHashMap>(); + private Map> atomicOperationMetadataMap = new LinkedHashMap<>(); public OAtomicUnitEndRecord() { } OAtomicUnitEndRecord(final OOperationUnitId operationUnitId, final boolean rollback, - final Map> atomicOperationMetadataMap) throws IOException { + final Map> atomicOperationMetadataMap) { super(operationUnitId); this.rollback = rollback; @@ -107,7 +105,7 @@ public int fromStream(final byte[] content, int offset) { rollback = content[offset] > 0; offset++; - atomicOperationMetadataMap = new LinkedHashMap>(); + atomicOperationMetadataMap = new LinkedHashMap<>(); final int metadataId = content[offset]; offset++; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OClusterAwareWALRecord.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OClusterAwareWALRecord.java deleted file mode 100755 index 0d503b17c52..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OClusterAwareWALRecord.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; - -/** - * @author Andrey Lomakin (a.lomakin-at-orientdb.com) - * @since 30.05.13 - */ -public interface OClusterAwareWALRecord { - int getClusterId(); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODirtyPage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODirtyPage.java deleted file mode 100755 index 7b64cbab234..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODirtyPage.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; - -/** - * @author Andrey Lomakin (a.lomakin-at-orientdb.com) - * @since 26.04.13 - */ -public class ODirtyPage { - public final String fileName; - public final long pageIndex; - private final OLogSequenceNumber lsn; - - public ODirtyPage(String fileName, long pageIndex, OLogSequenceNumber lsn) { - this.fileName = fileName; - this.pageIndex = pageIndex; - this.lsn = lsn; - } - - public String getFileName() { - return fileName; - } - - public long getPageIndex() { - return pageIndex; - } - - public OLogSequenceNumber getLsn() { - return lsn; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - ODirtyPage that = (ODirtyPage) o; - - if (pageIndex != that.pageIndex) - return false; - if (!fileName.equals(that.fileName)) - return false; - if (!lsn.equals(that.lsn)) - return false; - - return true; - } - - @Override - public int hashCode() { - int result = fileName.hashCode(); - result = 31 * result + (int) (pageIndex ^ (pageIndex >>> 32)); - result = 31 * result + lsn.hashCode(); - return result; - } - - @Override - public String toString() { - return "ODirtyPage{" + "fileName='" + fileName + '\'' + ", pageIndex=" + pageIndex + ", lsn=" + lsn + '}'; - } -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODiskWriteAheadLog.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODiskWriteAheadLog.java index c054f8eca18..f992d7092a6 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODiskWriteAheadLog.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/ODiskWriteAheadLog.java @@ -445,7 +445,7 @@ public OLogSequenceNumber end() { } @Override - public void flush() throws IOException { + public void flush() { OLogSegment last; syncObject.lock(); @@ -984,7 +984,7 @@ public void cutAllSegmentsSmallerThan(long segmentId) throws IOException { } @Override - public void preventCutTill(OLogSequenceNumber lsn) throws IOException { + public void preventCutTill(OLogSequenceNumber lsn) { preventCutTill = lsn; } @@ -995,7 +995,7 @@ private OLogSegment removeHeadSegmentFromList() { return logSegments.remove(0); } - private void recalculateLogSize() throws IOException { + private void recalculateLogSize() { logSize = 0; for (OLogSegment segment : logSegments) diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegment.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegment.java index 6a6a0e3bf10..fdea9f1b23f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegment.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegment.java @@ -73,7 +73,7 @@ public interface OLogSegment extends Comparable { /** * Writes buffer of the segment to the disk and performs fsync of data. */ - void flush() throws IOException; + void flush(); /** * Clears the buffer and deletes file content. @@ -84,7 +84,7 @@ public interface OLogSegment extends Comparable { * Stop background task which writes data from log segments buffer to the disk and writes the rest of the buffer * to the disk. Performs fsync if necessary. */ - void stopBackgroundWrite(boolean flush) throws IOException; + void stopBackgroundWrite(boolean flush); /** * Start background task which performs periodical write of background buffer to the disk. diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV1.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV1.java index 0f19454b537..6e4d59c2717 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV1.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV1.java @@ -230,7 +230,7 @@ public void startBackgroundWrite() { * {@inheritDoc} */ @Override - public void stopBackgroundWrite(boolean flush) throws IOException { + public void stopBackgroundWrite(boolean flush) { if (flush) flush(); @@ -554,7 +554,7 @@ public void close(boolean flush) throws IOException { * {@inheritDoc} */ @Override - public void flush() throws IOException { + public void flush() { writeData(); syncData(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV2.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV2.java index 63494b2efa5..dd134d211cf 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV2.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OLogSegmentV2.java @@ -252,7 +252,7 @@ public void startBackgroundWrite() { * {@inheritDoc} */ @Override - public void stopBackgroundWrite(boolean flush) throws IOException { + public void stopBackgroundWrite(boolean flush) { if (flush) flush(); @@ -667,7 +667,7 @@ public void close(boolean flush) throws IOException { * {@inheritDoc} */ @Override - public void flush() throws IOException { + public void flush() { writeData(); syncData(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OMemoryWriteAheadLog.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OMemoryWriteAheadLog.java index 59e99dc6ec9..557128db3f8 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OMemoryWriteAheadLog.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OMemoryWriteAheadLog.java @@ -116,7 +116,7 @@ public void moveLsnAfter(OLogSequenceNumber lsn) { } @Override - public void preventCutTill(OLogSequenceNumber lsn) throws IOException { + public void preventCutTill(OLogSequenceNumber lsn) { } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitBodyRecord.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitBodyRecord.java index ac2baa51db0..f849dcf7c97 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitBodyRecord.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitBodyRecord.java @@ -1,36 +1,28 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; -import com.orientechnologies.common.serialization.types.OLongSerializer; - /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) Andrey Lomakin * @since 31/12/14 */ public abstract class OOperationUnitBodyRecord extends OOperationUnitRecord { - protected OOperationUnitBodyRecord() { - } - - protected OOperationUnitBodyRecord(OOperationUnitId operationUnitId) { - super(operationUnitId); - } - + protected OOperationUnitBodyRecord() { + } - @Override - public int toStream(byte[] content, int offset) { - offset = super.toStream(content, offset); + protected OOperationUnitBodyRecord(OOperationUnitId operationUnitId) { + super(operationUnitId); + } - return offset; - } + @Override + public int toStream(byte[] content, int offset) { + offset = super.toStream(content, offset); - @Override - public int fromStream(byte[] content, int offset) { - offset = super.fromStream(content, offset); + return offset; + } - return offset; - } + @Override + public int fromStream(byte[] content, int offset) { + offset = super.fromStream(content, offset); - @Override - public int serializedSize() { - return super.serializedSize(); - } + return offset; + } } \ No newline at end of file diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitId.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitId.java index e57e841e4e2..fe4d524e474 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitId.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OOperationUnitId.java @@ -15,7 +15,6 @@ */ package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; -import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; import com.orientechnologies.common.serialization.types.OLongSerializer; @@ -30,8 +29,8 @@ public class OOperationUnitId { private static final AtomicLong sharedId = new AtomicLong(); - private static volatile ThreadLocal localId = new ThreadLocal(); - private static volatile ThreadLocal sharedIdCopy = new ThreadLocal(); + private static volatile ThreadLocal localId = new ThreadLocal<>(); + private static volatile ThreadLocal sharedIdCopy = new ThreadLocal<>(); public static final int SERIALIZED_SIZE = 2 * OLongSerializer.LONG_SIZE; @@ -40,10 +39,10 @@ public class OOperationUnitId { @Override public void onStartup() { if (localId == null) - localId = new ThreadLocal(); + localId = new ThreadLocal<>(); if (sharedIdCopy == null) - sharedIdCopy = new ThreadLocal(); + sharedIdCopy = new ThreadLocal<>(); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChanges.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChanges.java old mode 100644 new mode 100755 index 687e4a70f71..97e4d230cc2 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChanges.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChanges.java @@ -64,7 +64,7 @@ public interface OWALChanges { * Read changes from a stream. * Needed from restore from WAL. * - * @param offset the offest in the buffer where start to read. + * @param offset the offset in the buffer where start to read. * @param stream the buffer to read. * @return the offset+read bytes. */ diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChangesTree.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChangesTree.java index ed2e8807d58..28b408f9610 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChangesTree.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALChangesTree.java @@ -29,13 +29,14 @@ public void setDebug(boolean debug) { this.debug = debug; } + @Override public byte getByteValue(ByteBuffer buffer, int offset) { if (root == null && buffer != null) { return buffer.get(offset); } final int end = offset + OByteSerializer.BYTE_SIZE; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, offset, end, result); if (buffer != null && result.isEmpty()) @@ -47,6 +48,7 @@ public byte getByteValue(ByteBuffer buffer, int offset) { return value[0]; } + @Override public byte[] getBinaryValue(ByteBuffer buffer, int offset, int len) { if (root == null && buffer != null) { final byte[] value = new byte[len]; @@ -56,7 +58,7 @@ public byte[] getBinaryValue(ByteBuffer buffer, int offset, int len) { final int end = offset + len; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, offset, end, result); if (result.isEmpty() && buffer != null) { @@ -79,13 +81,14 @@ public byte[] getBinaryValue(ByteBuffer buffer, int offset, int len) { return value; } + @Override public short getShortValue(ByteBuffer buffer, int offset) { if (root == null && buffer != null) { return buffer.getShort(offset); } int end = offset + OShortSerializer.SHORT_SIZE; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, offset, end, result); if (result.isEmpty() && buffer != null) @@ -104,13 +107,14 @@ public short getShortValue(ByteBuffer buffer, int offset) { return OShortSerializer.INSTANCE.deserializeNative(value, 0); } + @Override public int getIntValue(ByteBuffer buffer, int offset) { if (root == null && buffer != null) { return buffer.getInt(offset); } int end = offset + OIntegerSerializer.INT_SIZE; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, offset, end, result); if (result.isEmpty() && buffer != null) @@ -129,13 +133,14 @@ public int getIntValue(ByteBuffer buffer, int offset) { return OIntegerSerializer.INSTANCE.deserializeNative(value, 0); } + @Override public long getLongValue(ByteBuffer buffer, int offset) { if (root == null && buffer != null) { return buffer.getLong(offset); } int end = offset + OLongSerializer.LONG_SIZE; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, offset, end, result); if (result.isEmpty() && buffer != null) @@ -156,16 +161,16 @@ public long getLongValue(ByteBuffer buffer, int offset) { @Override public void setIntValue(ByteBuffer buffer, int value, int offset) { - byte[] svalue = new byte[OIntegerSerializer.INT_SIZE]; - OIntegerSerializer.INSTANCE.serializeNative(value, svalue, 0); - add(svalue, offset); + byte[] sValue = new byte[OIntegerSerializer.INT_SIZE]; + OIntegerSerializer.INSTANCE.serializeNative(value, sValue, 0); + add(sValue, offset); } @Override public void setLongValue(ByteBuffer buffer, long value, int offset) { - byte[] svalue = new byte[OLongSerializer.LONG_SIZE]; - OLongSerializer.INSTANCE.serializeNative(value, svalue, 0); - add(svalue, offset); + byte[] sValue = new byte[OLongSerializer.LONG_SIZE]; + OLongSerializer.INSTANCE.serializeNative(value, sValue, 0); + add(sValue, offset); } @Override @@ -194,11 +199,11 @@ private void add(byte[] value, int start, int version, boolean updateSerializedS if (value == null || value.length == 0) return; - final Node fnode = bsearch(start); + final Node fNode = bSearch(start); final Node node = new Node(value, start, RED, version); - if (fnode == null) { + if (fNode == null) { root = node; root.color = BLACK; @@ -211,18 +216,18 @@ private void add(byte[] value, int start, int version, boolean updateSerializedS return; } - if (start < fnode.start) { - fnode.left = node; - node.parent = fnode; + if (start < fNode.start) { + fNode.left = node; + node.parent = fNode; if (updateSerializedSize) serializedSize += serializedSize(value.length); updateMaxEndAfterAppend(node); insertCaseOne(node); - } else if (start > fnode.start) { - fnode.right = node; - node.parent = fnode; + } else if (start > fNode.start) { + fNode.right = node; + node.parent = fNode; if (updateSerializedSize) serializedSize += serializedSize(value.length); @@ -231,56 +236,56 @@ private void add(byte[] value, int start, int version, boolean updateSerializedS insertCaseOne(node); } else { final int end = start + value.length; - if (end == fnode.end) { - if (fnode.version < version) { + if (end == fNode.end) { + if (fNode.version < version) { if (updateSerializedSize) - serializedSize -= fnode.value.length; + serializedSize -= fNode.value.length; - fnode.value = value; - fnode.version = version; + fNode.value = value; + fNode.version = version; if (updateSerializedSize) - serializedSize += fnode.value.length; + serializedSize += fNode.value.length; } - } else if (end < fnode.end) { - if (fnode.version < version) { - final byte[] cvalue = Arrays.copyOfRange(fnode.value, end - start, fnode.end - start); - final int cversion = fnode.version; - final int cstart = end; + } else if (end < fNode.end) { + if (fNode.version < version) { + final byte[] cValue = Arrays.copyOfRange(fNode.value, end - start, fNode.end - start); + final int cVersion = fNode.version; + final int cStart = end; if (updateSerializedSize) - serializedSize -= fnode.value.length; + serializedSize -= fNode.value.length; - fnode.end = end; - fnode.value = value; - fnode.version = version; + fNode.end = end; + fNode.value = value; + fNode.version = version; if (updateSerializedSize) - serializedSize += fnode.value.length; + serializedSize += fNode.value.length; - updateMaxEndAccordingToChildren(fnode); + updateMaxEndAccordingToChildren(fNode); - add(cvalue, cstart, cversion, updateSerializedSize); + add(cValue, cStart, cVersion, updateSerializedSize); } } else { - if (fnode.version > version) { - final byte[] cvalue = Arrays.copyOfRange(value, fnode.end - start, end - start); - final int cversion = version; - final int cstart = fnode.end; + if (fNode.version > version) { + final byte[] cValue = Arrays.copyOfRange(value, fNode.end - start, end - start); + final int cVersion = version; + final int cStart = fNode.end; - add(cvalue, cstart, cversion, updateSerializedSize); + add(cValue, cStart, cVersion, updateSerializedSize); } else { if (updateSerializedSize) - serializedSize -= fnode.value.length; + serializedSize -= fNode.value.length; - fnode.end = end; - fnode.value = value; - fnode.version = version; + fNode.end = end; + fNode.value = value; + fNode.version = version; if (updateSerializedSize) - serializedSize += fnode.value.length; + serializedSize += fNode.value.length; - updateMaxEndAccordingToChildren(fnode); + updateMaxEndAccordingToChildren(fNode); } } } @@ -291,12 +296,13 @@ private void add(byte[] value, int start, int version, boolean updateSerializedS public void applyChanges(byte[] values, int start) { final int end = start + values.length; - final List result = new ArrayList(); + final List result = new ArrayList<>(); findIntervals(root, start, end, result); applyChanges(values, start, end, result); } + @Override public int serializedSize() { return serializedSize; } @@ -309,7 +315,7 @@ private void applyChanges(byte[] values, int start, int end, List result) if (result.isEmpty()) return; - final Queue processedNodes = new ArrayDeque(); + final Queue processedNodes = new ArrayDeque<>(); for (Node activeNode : result) { int activeStart = activeNode.start; @@ -356,11 +362,12 @@ private void applyChanges(byte[] values, int start, int end, List result) } } + @Override public void applyChanges(ByteBuffer buffer) { if (root == null) return; - final Queue processedNodes = new ArrayDeque(); + final Queue processedNodes = new ArrayDeque<>(); applyChanges(buffer, root, processedNodes); } @@ -368,6 +375,7 @@ public int getSerializedSize() { return serializedSize; } + @Override public int fromStream(int offset, byte[] stream) { serializedSize = OIntegerSerializer.INSTANCE.deserializeNative(stream, offset); int readBytes = OIntegerSerializer.INT_SIZE; @@ -393,6 +401,7 @@ public int fromStream(int offset, byte[] stream) { return offset + readBytes; } + @Override public int toStream(int offset, byte[] stream) { OIntegerSerializer.INSTANCE.serializeNative(serializedSize, stream, offset); offset += OIntegerSerializer.INT_SIZE; @@ -468,7 +477,7 @@ private void assertInvariants() { } private boolean allBlackPathsAreEqual() { - List paths = new ArrayList(); + List paths = new ArrayList<>(); OModifiableInteger currentPath = new OModifiableInteger(); paths.add(currentPath); @@ -586,6 +595,7 @@ private boolean maxEndValueIsCorrect(Node node) { return true; } + @SuppressWarnings("BooleanMethodIsAlwaysInverted") private boolean valueIsMaxEndValueAmongChildren(Node node, int value) { if (node.end > value) return false; @@ -619,7 +629,7 @@ private void findIntervals(Node node, int start, int end, List result) { findIntervals(node.right, start, end, result); } - private Node bsearch(int start) { + private Node bSearch(int start) { if (root == null) return null; @@ -805,9 +815,9 @@ private static final class Node { private byte[] value; private int version; - private int start; - private int end; - private int maxEnd; + private final int start; + private int end; + private int maxEnd; private Node parent; private Node left; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageBrokenException.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageBrokenException.java index e5649df166a..6e11ffe56de 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageBrokenException.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageBrokenException.java @@ -20,7 +20,6 @@ package com.orientechnologies.orient.core.storage.impl.local.paginated.wal; -import com.orientechnologies.common.exception.OException; import com.orientechnologies.common.exception.OSystemException; /** diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageChangesPortion.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageChangesPortion.java old mode 100644 new mode 100755 index eb59817a755..6c227803ca1 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageChangesPortion.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALPageChangesPortion.java @@ -16,9 +16,9 @@ public class OWALPageChangesPortion implements OWALChanges { private static final int PAGE_SIZE = OGlobalConfiguration.DISK_CACHE_PAGE_SIZE.getValueAsInteger() * 1024; - public static final int CHUNK_SIZE = 32; - public static final int PORTION_SIZE = 32; - public static final int PORTION_BYTES = PORTION_SIZE * CHUNK_SIZE; + private static final int CHUNK_SIZE = 32; + private static final int PORTION_SIZE = 32; + static final int PORTION_BYTES = PORTION_SIZE * CHUNK_SIZE; private byte[][][] pageChunks; private final int pageSize; @@ -34,6 +34,7 @@ public OWALPageChangesPortion(int pageSize) { } } + @Override public void setLongValue(ByteBuffer pointer, long value, int offset) { byte[] data = new byte[OLongSerializer.LONG_SIZE]; OLongSerializer.INSTANCE.serializeNative(value, data, 0); @@ -41,6 +42,7 @@ public void setLongValue(ByteBuffer pointer, long value, int offset) { updateData(pointer, offset, data); } + @Override public void setIntValue(ByteBuffer pointer, int value, int offset) { byte[] data = new byte[OIntegerSerializer.INT_SIZE]; OIntegerSerializer.INSTANCE.serializeNative(value, data, 0); @@ -55,22 +57,26 @@ public void setShortValue(ByteBuffer pointer, short value, int offset) { updateData(pointer, offset, data); } + @Override public void setByteValue(ByteBuffer pointer, byte value, int offset) { byte[] data = new byte[] { value }; updateData(pointer, offset, data); } + @Override public void setBinaryValue(ByteBuffer pointer, byte[] value, int offset) { updateData(pointer, offset, value); } + @Override public void moveData(ByteBuffer pointer, int from, int to, int len) { byte[] buff = new byte[len]; readData(pointer, from, buff); updateData(pointer, to, buff); } + @Override public long getLongValue(ByteBuffer pointer, int offset) { byte[] data = new byte[OLongSerializer.LONG_SIZE]; @@ -79,6 +85,7 @@ public long getLongValue(ByteBuffer pointer, int offset) { return OLongSerializer.INSTANCE.deserializeNative(data, 0); } + @Override public int getIntValue(ByteBuffer pointer, int offset) { byte[] data = new byte[OIntegerSerializer.INT_SIZE]; @@ -87,6 +94,7 @@ public int getIntValue(ByteBuffer pointer, int offset) { return OIntegerSerializer.INSTANCE.deserializeNative(data, 0); } + @Override public short getShortValue(ByteBuffer pointer, int offset) { byte[] data = new byte[OShortSerializer.SHORT_SIZE]; @@ -95,6 +103,7 @@ public short getShortValue(ByteBuffer pointer, int offset) { return OShortSerializer.INSTANCE.deserializeNative(data, 0); } + @Override public byte getByteValue(ByteBuffer pointer, int offset) { byte[] data = new byte[1]; @@ -103,6 +112,7 @@ public byte getByteValue(ByteBuffer pointer, int offset) { return data[0]; } + @Override public byte[] getBinaryValue(ByteBuffer pointer, int offset, int len) { byte[] data = new byte[len]; readData(pointer, offset, data); @@ -110,6 +120,7 @@ public byte[] getBinaryValue(ByteBuffer pointer, int offset, int len) { return data; } + @Override public void applyChanges(ByteBuffer pointer) { if (pageChunks == null) return; @@ -126,15 +137,16 @@ public void applyChanges(ByteBuffer pointer) { } } + @Override public int serializedSize() { if (pageChunks == null) { return OShortSerializer.SHORT_SIZE; } int offset = OShortSerializer.SHORT_SIZE; - for (int i = 0; i < pageChunks.length; i++) { - if (pageChunks[i] != null) { + for (byte[][] pageChunk : pageChunks) { + if (pageChunk != null) { for (int j = 0; j < PORTION_SIZE; j++) { - if (pageChunks[i][j] != null) { + if (pageChunk[j] != null) { offset += OByteSerializer.BYTE_SIZE; offset += OByteSerializer.BYTE_SIZE; offset += CHUNK_SIZE; @@ -145,6 +157,7 @@ public int serializedSize() { return offset; } + @Override public int toStream(int offset, byte[] stream) { if (pageChunks == null) { OShortSerializer.INSTANCE.serializeNative((short) 0, stream, offset); @@ -172,6 +185,7 @@ public int toStream(int offset, byte[] stream) { return offset; } + @Override public int fromStream(int offset, byte[] stream) { int chunkLength = OShortSerializer.INSTANCE.deserializeNative(stream, offset); offset += OShortSerializer.SHORT_SIZE; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALRecordsFactory.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALRecordsFactory.java index dacca4b3362..691642d07b5 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALRecordsFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWALRecordsFactory.java @@ -28,8 +28,8 @@ * @since 25.04.13 */ public class OWALRecordsFactory { - private Map idToTypeMap = new HashMap(); - private Map typeToIdMap = new HashMap(); + private final Map idToTypeMap = new HashMap<>(); + private final Map typeToIdMap = new HashMap<>(); public static final OWALRecordsFactory INSTANCE = new OWALRecordsFactory(); @@ -109,9 +109,7 @@ public OWALRecord fromStream(byte[] content) { if (idToTypeMap.containsKey(content[0])) try { walRecord = (OWALRecord) idToTypeMap.get(content[0]).newInstance(); - } catch (InstantiationException e) { - throw new IllegalStateException("Cannot deserialize passed in record", e); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { throw new IllegalStateException("Cannot deserialize passed in record", e); } else diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWriteAheadLog.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWriteAheadLog.java index 3f138a31917..6541ba91285 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWriteAheadLog.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/wal/OWriteAheadLog.java @@ -49,7 +49,7 @@ public interface OWriteAheadLog { OLogSequenceNumber end(); - void flush() throws IOException; + void flush(); OLogSequenceNumber logAtomicOperationStartRecord(boolean isRollbackSupported, OOperationUnitId unitId) throws IOException; @@ -88,7 +88,7 @@ OLogSequenceNumber logAtomicOperationEndRecord(OOperationUnitId operationUnitId, void moveLsnAfter(OLogSequenceNumber lsn) throws IOException; - void preventCutTill(OLogSequenceNumber lsn) throws IOException; + void preventCutTill(OLogSequenceNumber lsn); File[] nonActiveSegments(long fromSegment); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OClusterCountersHolder.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OClusterCountersHolder.java old mode 100644 new mode 100755 index af856641721..0470b85995d --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OClusterCountersHolder.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OClusterCountersHolder.java @@ -33,13 +33,13 @@ public class OClusterCountersHolder extends OSessionStoragePerformanceStatistic. */ long timeRecordCreation; - long createRecordPages; + private long createRecordPages; - long createRecordFilePages; + private long createRecordFilePages; - long createRecordPageReadTime; + private long createRecordPageReadTime; - long createRecordFilePageReadTime; + private long createRecordFilePageReadTime; /** * Amount of all deleted records @@ -51,13 +51,13 @@ public class OClusterCountersHolder extends OSessionStoragePerformanceStatistic. */ long timeRecordDeletion; - long deleteRecordPages; + private long deleteRecordPages; - long deleteRecordFilePages; + private long deleteRecordFilePages; - long deleteRecordPageReadTime = 0; + private long deleteRecordPageReadTime = 0; - long deleteRecordFilePageReadTime = 0; + private long deleteRecordFilePageReadTime = 0; /** * Amount of all updated records @@ -69,13 +69,13 @@ public class OClusterCountersHolder extends OSessionStoragePerformanceStatistic. */ long timeRecordUpdate; - long updateRecordPages; + private long updateRecordPages; - long updateRecordFilePages; + private long updateRecordFilePages; - long updateRecordPageReadTime; + private long updateRecordPageReadTime; - long updateRecordFilePageReadTime; + private long updateRecordFilePageReadTime; /** * Amount of all read records @@ -87,13 +87,13 @@ public class OClusterCountersHolder extends OSessionStoragePerformanceStatistic. */ long timeRecordRead; - long readRecordPages; + private long readRecordPages; - long readRecordFilePages; + private long readRecordFilePages; - long readRecordPageReadTime; + private long readRecordPageReadTime; - long readRecordFilePageReadTime; + private long readRecordFilePageReadTime; @Override public OClusterCountersHolder newInstance() { @@ -304,6 +304,7 @@ public ODocument toDocument() { return document; } + @SuppressWarnings("unused") public class CreateRecordOperation extends OOperation { @Override void incrementOperationsCounter(int pages, int filePages) { @@ -312,6 +313,7 @@ void incrementOperationsCounter(int pages, int filePages) { } } + @SuppressWarnings("unused") public class UpdateRecordOperation extends OOperation { @Override void incrementOperationsCounter(int pages, int filePages) { @@ -320,6 +322,7 @@ void incrementOperationsCounter(int pages, int filePages) { } } + @SuppressWarnings("unused") public class DeleteRecordPages extends OOperation { @Override void incrementOperationsCounter(int pages, int filePages) { @@ -328,6 +331,7 @@ void incrementOperationsCounter(int pages, int filePages) { } } + @SuppressWarnings("unused") public class ReadRecordPages extends OOperation { @Override void incrementOperationsCounter(int pages, int filePages) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OOperation.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OOperation.java old mode 100644 new mode 100755 index 26387e4993b..33b90b4f875 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OOperation.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OOperation.java @@ -20,6 +20,7 @@ /** * @author Andrey Lomakin (a.lomakin-at-orientdb.com) */ +@SuppressWarnings("unused") public abstract class OOperation { abstract void incrementOperationsCounter(int pages, int filePages); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java old mode 100644 new mode 100755 index ad572a98323..db4bf9e176d --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java @@ -82,9 +82,9 @@ public class OPerformanceStatisticManager { /** * Prefix of name of JMX bean. */ - public static final String MBEAN_PREFIX = "com.orientechnologies.orient.core.storage.impl.local.statistic:type=OPerformanceStatisticManagerMXBean"; + private static final String MBEAN_PREFIX = "com.orientechnologies.orient.core.storage.impl.local.statistic:type=OPerformanceStatisticManagerMXBean"; - /** + /* * Class consist of three key fields: *

*

    @@ -128,17 +128,12 @@ public class OPerformanceStatisticManager { /** * Indicates whether gathering of performance data for single thread is switched on/off. */ - private final ThreadLocal enabledForCurrentThread = new ThreadLocal() { - @Override - protected Boolean initialValue() { - return false; - } - }; + private final ThreadLocal enabledForCurrentThread = ThreadLocal.withInitial(() -> false); /** * Map which bounds performance statistic for currently running threads. */ - private final ConcurrentHashMap statistics = new ConcurrentHashMap(); + private final ConcurrentHashMap statistics = new ConcurrentHashMap<>(); /** * Accumulated statistic for threads which were active during early stages of performance measurement and are died now. @@ -163,7 +158,7 @@ protected Boolean initialValue() { /** * List of all components which registered itself as participating in performance monitoring. */ - private final List componentNames = new CopyOnWriteArrayList(); + private final List componentNames = new CopyOnWriteArrayList<>(); /** * Amount of full checkpoints are done for current storage. @@ -384,7 +379,7 @@ public void stopMonitoring() { enabled = false; final PerformanceCountersHolder countersHolder = ComponentType.GENERAL.newCountersHolder(); - final Map componentCountersHolder = new HashMap(); + final Map componentCountersHolder = new HashMap<>(); WritCacheCountersHolder writCacheCountersHolder = deadThreadsStatistic.writCacheCountersHolder; StorageCountersHolder storageCountersHolder = deadThreadsStatistic.storageCountersHolder; @@ -435,13 +430,7 @@ public void registerMBean(String storageName, int storageId) { + " or you have several running applications which use OrientDB engine inside", mbeanName.getCanonicalName()); } - } catch (MalformedObjectNameException e) { - throw OException.wrapException(new OStorageException("Error during registration of profiler MBean"), e); - } catch (InstanceAlreadyExistsException e) { - throw OException.wrapException(new OStorageException("Error during registration of profiler MBean"), e); - } catch (MBeanRegistrationException e) { - throw OException.wrapException(new OStorageException("Error during registration of profiler MBean"), e); - } catch (NotCompliantMBeanException e) { + } catch (MalformedObjectNameException | InstanceAlreadyExistsException | NotCompliantMBeanException | MBeanRegistrationException e) { throw OException.wrapException(new OStorageException("Error during registration of profiler MBean"), e); } } @@ -466,11 +455,7 @@ public void unregisterMBean(String storageName, int storageId) { final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); final ObjectName mbeanName = new ObjectName(getMBeanName(storageName, storageId)); server.unregisterMBean(mbeanName); - } catch (MalformedObjectNameException e) { - throw OException.wrapException(new OStorageException("Error during unregistration of profiler MBean"), e); - } catch (InstanceNotFoundException e) { - throw OException.wrapException(new OStorageException("Error during unregistration of profiler MBean"), e); - } catch (MBeanRegistrationException e) { + } catch (MalformedObjectNameException | InstanceNotFoundException | MBeanRegistrationException e) { throw OException.wrapException(new OStorageException("Error during unregistration of profiler MBean"), e); } } @@ -489,7 +474,7 @@ public void registerComponent(String component) { * @return Set of names of components for which performance statistic is gathered. */ public Set getComponentNames() { - return new HashSet(componentNames); + return new HashSet<>(componentNames); } /** @@ -1191,15 +1176,14 @@ private WritCacheCountersHolder fetchWriteCacheCounters() { //To decrease inter thread communication delay we fetch snapshots first //and only after that we aggregate data from immutable snapshots - final Collection> snapshots = new ArrayList>( - statistics.size()); + final Collection> snapshots = new ArrayList<>(statistics.size()); - final Collection threadsToRemove = new ArrayList(); + final Collection threadsToRemove = new ArrayList<>(); for (Map.Entry entry : statistics.entrySet()) { final Thread thread = entry.getKey(); final OSessionStoragePerformanceStatistic statistic = entry.getValue(); - snapshots.add(new ORawPair(thread, statistic.getSnapshot())); + snapshots.add(new ORawPair<>(thread, statistic.getSnapshot())); } WritCacheCountersHolder holder = null; @@ -1252,15 +1236,14 @@ private StorageCountersHolder fetchStorageCounters() { //To decrease inter thread communication delay we fetch snapshots first //and only after that we aggregate data from immutable snapshots - final Collection> snapshots = new ArrayList>( - statistics.size()); + final Collection> snapshots = new ArrayList<>(statistics.size()); - final Collection threadsToRemove = new ArrayList(); + final Collection threadsToRemove = new ArrayList<>(); for (Map.Entry entry : statistics.entrySet()) { final Thread thread = entry.getKey(); final OSessionStoragePerformanceStatistic statistic = entry.getValue(); - snapshots.add(new ORawPair(thread, statistic.getSnapshot())); + snapshots.add(new ORawPair<>(thread, statistic.getSnapshot())); } StorageCountersHolder holder = null; @@ -1313,15 +1296,14 @@ private WALCountersHolder fetchWALCounters() { //To decrease inter thread communication delay we fetch snapshots first //and only after that we aggregate data from immutable snapshots - final Collection> snapshots = new ArrayList>( - statistics.size()); + final Collection> snapshots = new ArrayList<>(statistics.size()); - final Collection threadsToRemove = new ArrayList(); + final Collection threadsToRemove = new ArrayList<>(); for (Map.Entry entry : statistics.entrySet()) { final Thread thread = entry.getKey(); final OSessionStoragePerformanceStatistic statistic = entry.getValue(); - snapshots.add(new ORawPair(thread, statistic.getSnapshot())); + snapshots.add(new ORawPair<>(thread, statistic.getSnapshot())); } WALCountersHolder holder = null; @@ -1374,14 +1356,13 @@ private void fetchSystemCounters(PerformanceCountersHolder countersHolder) { //To decrease inter thread communication delay we fetch snapshots first //and only after that we aggregate data from immutable snapshots - final Collection> snapshots = new ArrayList>( - statistics.size()); + final Collection> snapshots = new ArrayList<>(statistics.size()); - final Collection threadsToRemove = new ArrayList(); + final Collection threadsToRemove = new ArrayList<>(); for (Map.Entry entry : statistics.entrySet()) { final Thread thread = entry.getKey(); final OSessionStoragePerformanceStatistic statistic = entry.getValue(); - snapshots.add(new ORawPair(thread, statistic.getSnapshot())); + snapshots.add(new ORawPair<>(thread, statistic.getSnapshot())); } for (ORawPair pair : snapshots) { @@ -1421,14 +1402,13 @@ private void fetchComponentCounters(String componentName, PerformanceCountersHol //To decrease inter thread communication delay we fetch snapshots first //and only after that we aggregate data from immutable snapshots - final Collection> snapshots = new ArrayList>( - statistics.size()); + final Collection> snapshots = new ArrayList<>(statistics.size()); - final List threadsToRemove = new ArrayList(); + final List threadsToRemove = new ArrayList<>(); for (Map.Entry entry : statistics.entrySet()) { final Thread thread = entry.getKey(); final OSessionStoragePerformanceStatistic statistic = entry.getValue(); - snapshots.add(new ORawPair(thread, statistic.getSnapshot())); + snapshots.add(new ORawPair<>(thread, statistic.getSnapshot())); } for (ORawPair pair : snapshots) { @@ -1468,7 +1448,7 @@ private void updateDeadThreadsStatistic(Collection threadsToRemove) { //results in #deadThreadsStatistic field to preserve thread safety features final ImmutableStatistic oldDS = deadThreadsStatistic; final PerformanceCountersHolder countersHolder = ComponentType.GENERAL.newCountersHolder(); - final Map countersByComponents = new HashMap(); + final Map countersByComponents = new HashMap<>(); WritCacheCountersHolder writeCacheCountersHolder = null; StorageCountersHolder storageCountersHolder = null; diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManagerMBean.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManagerMBean.java index 7b3ef26578e..b6aa6fbcb04 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManagerMBean.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManagerMBean.java @@ -35,122 +35,122 @@ public class OPerformanceStatisticManagerMBean implements DynamicMBean { /** * Name of "pagesPerOperation" performance attribute */ - public static final String PAGES_PER_OPERATION = "pagesPerOperation"; + private static final String PAGES_PER_OPERATION = "pagesPerOperation"; /** * Name of "cacheHits" performance attribute */ - public static final String CACHE_HITS = "cacheHits"; + private static final String CACHE_HITS = "cacheHits"; /** * Separator in property name between component name and name of performance attribute */ - public static final String COMPONENT_SEPARATOR = "_"; + private static final String COMPONENT_SEPARATOR = "_"; /** * Name of "commitTime" performance attribute */ - public static final String COMMIT_TIME = "commitTime"; + private static final String COMMIT_TIME = "commitTime"; /** * Name of "readSpeedFromCache" performance attribute */ - public static final String READ_SPEED_FROM_CACHE = "readSpeedFromCache"; + private static final String READ_SPEED_FROM_CACHE = "readSpeedFromCache"; /** * Name of "readSpeedFromFile" performance attribute */ - public static final String READ_SPEED_FROM_FILE = "readSpeedFromFile"; + private static final String READ_SPEED_FROM_FILE = "readSpeedFromFile"; /** * Name of "writeSpeedInCache" performance attribute */ - public static final String WRITE_SPEED_IN_CACHE = "writeSpeedInCache"; + private static final String WRITE_SPEED_IN_CACHE = "writeSpeedInCache"; /** * Name of "startMonitoring" method */ - public static final String START_MONITORING = "startMonitoring"; + private static final String START_MONITORING = "startMonitoring"; /** * Name of "stopMonitoring" method */ - public static final String STOP_MONITORING = "stopMonitoring"; + private static final String STOP_MONITORING = "stopMonitoring"; /** * Name of "writeCachePagesPerFlush" performance attribute */ - public static final String WRITE_CACHE_PAGES_PER_FLUSH = "writeCachePagesPerFlush"; + private static final String WRITE_CACHE_PAGES_PER_FLUSH = "writeCachePagesPerFlush"; /** * Name of "writeCacheFlushOperationsTime" performance attribute */ - public static final String WRITE_CACHE_FLUSH_OPERATION_TIME = "writeCacheFlushOperationTime"; + private static final String WRITE_CACHE_FLUSH_OPERATION_TIME = "writeCacheFlushOperationTime"; /** * Name of "writeCacheFuzzyCheckpointTime" performance attribute */ - public static final String WRITE_CACHE_FUZZY_CHECKPOINT_TIME = "writeCacheFuzzyCheckpointTime"; + private static final String WRITE_CACHE_FUZZY_CHECKPOINT_TIME = "writeCacheFuzzyCheckpointTime"; /** * Name of "fullCheckpointTime" performance attribute */ - public static final String FULL_CHECKPOINT_TIME = "fullCheckpointTime"; + private static final String FULL_CHECKPOINT_TIME = "fullCheckpointTime"; /** * Name of "fullCheckpointCount" performance attribute */ - public static final String FULL_CHECKPOINT_COUNT = "fullCheckpointCount"; + private static final String FULL_CHECKPOINT_COUNT = "fullCheckpointCount"; /** * Name of "readCacheSize" performance attribute */ - public static final String READ_CACHE_SIZE = "readCacheSize"; + private static final String READ_CACHE_SIZE = "readCacheSize"; /** * Name of "writeCacheSize" performance attribute */ - public static final String WRITE_CACHE_SIZE = "writeCacheSize"; + private static final String WRITE_CACHE_SIZE = "writeCacheSize"; /** * Name of "exclusiveWriteCacheSize" performance attribute */ - public static final String EXCLUSIVE_WRITE_CACHE_SIZE = "exclusiveWriteCacheSize"; + private static final String EXCLUSIVE_WRITE_CACHE_SIZE = "exclusiveWriteCacheSize"; /** * Name of "writeCacheOverflowCount" performance attribute */ - public static final String WRITE_CACHE_OVERFLOW_COUNT = "writeCacheOverflowCount"; + private static final String WRITE_CACHE_OVERFLOW_COUNT = "writeCacheOverflowCount"; /** * Name of "walSize" performance attribute */ - public static final String WAL_SIZE = "walSize"; + private static final String WAL_SIZE = "walSize"; /** * Name of "walCacheOverflowCount" performance attribute */ - public static final String WAL_CACHE_OVERFLOW_COUNT = "walCacheOverflowCount"; + private static final String WAL_CACHE_OVERFLOW_COUNT = "walCacheOverflowCount"; /** * Name of "walLogTime" performance attribute */ - public static final String WAL_LOG_TIME = "walLogTime"; + private static final String WAL_LOG_TIME = "walLogTime"; /** * Name of "walStartAOLogTime" performance attribute */ - public static final String WAL_START_AO_LOG_TIME = "walStartAOLogTime"; + private static final String WAL_START_AO_LOG_TIME = "walStartAOLogTime"; /** * Name of "walEndAOLogTime" performance attribute */ - public static final String WAL_END_AO_LOG_TIME = "walEndAOLogTime"; + private static final String WAL_END_AO_LOG_TIME = "walEndAOLogTime"; /** * Name of "walFlushTime" performance attribute */ - public static final String WAL_FLUSH_TIME = "walFlushTime"; + private static final String WAL_FLUSH_TIME = "walFlushTime"; /** * Reference to related performance manager @@ -192,113 +192,129 @@ public Object getAttribute(String attribute) throws AttributeNotFoundException, } //if attribute name does not include component name it is system wide not component wide attribute - if (attributeName.equals(CACHE_HITS)) { + switch (attributeName) { + case CACHE_HITS: if (componentName == null) return manager.getCacheHits(); else { return manager.getCacheHits(componentName); } - } else if (attributeName.equals(COMMIT_TIME)) { + case COMMIT_TIME: if (componentName == null) return manager.getCommitTime(); else return throwComponentsAreNotSupported(COMMIT_TIME); - } else if (attributeName.equals(READ_SPEED_FROM_CACHE)) { + case READ_SPEED_FROM_CACHE: if (componentName == null) return manager.getReadSpeedFromCacheInPages(); else return manager.getReadSpeedFromCacheInPages(componentName); - } else if (attributeName.equals(READ_SPEED_FROM_FILE)) { + case READ_SPEED_FROM_FILE: if (componentName == null) return manager.getReadSpeedFromFileInPages(); else return manager.getReadSpeedFromFileInPages(componentName); - } else if (attributeName.equals(WRITE_SPEED_IN_CACHE)) { + case WRITE_SPEED_IN_CACHE: if (componentName == null) return manager.getWriteSpeedInCacheInPages(); else return manager.getWriteSpeedInCacheInPages(componentName); - } else if (attributeName.equals(PAGES_PER_OPERATION)) { + case PAGES_PER_OPERATION: if (componentName == null) throw new RuntimeOperationsException(new IllegalArgumentException("Unknown attribute"), "Amount of pages per operation is measured only on component level"); return manager.getAmountOfPagesPerOperation(componentName); - } else if (attributeName.equals(WRITE_CACHE_PAGES_PER_FLUSH)) { + case WRITE_CACHE_PAGES_PER_FLUSH: if (componentName == null) return manager.getWriteCachePagesPerFlush(); else throwComponentsAreNotSupported(WRITE_CACHE_PAGES_PER_FLUSH); - } else if (attributeName.equals(WRITE_CACHE_FLUSH_OPERATION_TIME)) { + break; + case WRITE_CACHE_FLUSH_OPERATION_TIME: if (componentName == null) return manager.getWriteCacheFlushOperationsTime(); else throwComponentsAreNotSupported(WRITE_CACHE_FLUSH_OPERATION_TIME); - } else if (attributeName.equals(WRITE_CACHE_FUZZY_CHECKPOINT_TIME)) { + break; + case WRITE_CACHE_FUZZY_CHECKPOINT_TIME: if (componentName == null) return manager.getWriteCacheFuzzyCheckpointTime(); else throwComponentsAreNotSupported(WRITE_CACHE_FUZZY_CHECKPOINT_TIME); - } else if (attributeName.equals(FULL_CHECKPOINT_TIME)) { + break; + case FULL_CHECKPOINT_TIME: if (componentName == null) return manager.getFullCheckpointTime(); else throwComponentsAreNotSupported(FULL_CHECKPOINT_TIME); - } else if (attributeName.equals(FULL_CHECKPOINT_COUNT)) { + break; + case FULL_CHECKPOINT_COUNT: if (componentName == null) return manager.getFullCheckpointCount(); else throwComponentsAreNotSupported(FULL_CHECKPOINT_COUNT); - } else if (attributeName.equals(READ_CACHE_SIZE)) { + break; + case READ_CACHE_SIZE: if (componentName == null) return manager.getReadCacheSize(); else throwComponentsAreNotSupported(READ_CACHE_SIZE); - } else if (attributeName.equals(WRITE_CACHE_SIZE)) { + break; + case WRITE_CACHE_SIZE: if (componentName == null) return manager.getWriteCacheSize(); else throwComponentsAreNotSupported(WRITE_CACHE_SIZE); - } else if (attributeName.equals(EXCLUSIVE_WRITE_CACHE_SIZE)) { + break; + case EXCLUSIVE_WRITE_CACHE_SIZE: if (componentName == null) return manager.getExclusiveWriteCacheSize(); else throwComponentsAreNotSupported(EXCLUSIVE_WRITE_CACHE_SIZE); - } else if (attributeName.equals(WRITE_CACHE_OVERFLOW_COUNT)) { + break; + case WRITE_CACHE_OVERFLOW_COUNT: if (componentName == null) return manager.getWriteCacheOverflowCount(); else throwComponentsAreNotSupported(WAL_CACHE_OVERFLOW_COUNT); - } else if (attributeName.equals(WAL_SIZE)) { + break; + case WAL_SIZE: if (componentName == null) return manager.getWALSize(); else throwComponentsAreNotSupported(WAL_SIZE); - } else if (attributeName.equals(WAL_CACHE_OVERFLOW_COUNT)) { + break; + case WAL_CACHE_OVERFLOW_COUNT: if (componentName == null) return manager.getWALCacheOverflowCount(); else throwComponentsAreNotSupported(WAL_CACHE_OVERFLOW_COUNT); - } else if (attributeName.equals(WAL_LOG_TIME)) { + break; + case WAL_LOG_TIME: if (componentName == null) return manager.getWALLogRecordTime(); else throwComponentsAreNotSupported(WAL_LOG_TIME); - } else if (attributeName.equals(WAL_START_AO_LOG_TIME)) { + break; + case WAL_START_AO_LOG_TIME: if (componentName == null) return manager.getWALStartAOLogRecordTime(); else throwComponentsAreNotSupported(WAL_START_AO_LOG_TIME); - } else if (attributeName.equals(WAL_END_AO_LOG_TIME)) { + break; + case WAL_END_AO_LOG_TIME: if (componentName == null) return manager.getWALStopAOLogRecordTime(); else throwComponentsAreNotSupported(WAL_END_AO_LOG_TIME); - } else if (attributeName.equals(WAL_FLUSH_TIME)) { + break; + case WAL_FLUSH_TIME: if (componentName == null) return manager.getWALFlushTime(); else throwComponentsAreNotSupported(WAL_FLUSH_TIME); + break; } throw new AttributeNotFoundException("Cannot find " + attribute + " attribute in " + getClass().getSimpleName()); @@ -373,10 +389,10 @@ public Object invoke(String actionName, Object[] params, String[] signature) thr @Override public MBeanInfo getMBeanInfo() { - final List performanceAttributes = new ArrayList(); + final List performanceAttributes = new ArrayList<>(); populatePerformanceAttributes(performanceAttributes); - final List operations = new ArrayList(); + final List operations = new ArrayList<>(); final MBeanOperationInfo startMonitoring = new MBeanOperationInfo(START_MONITORING, "Starts monitoring OrientDB performance characteristics", new MBeanParameterInfo[0], void.class.getName(), diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OSessionStoragePerformanceStatistic.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OSessionStoragePerformanceStatistic.java index 7e67ae99224..e9758b83fe1 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OSessionStoragePerformanceStatistic.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OSessionStoragePerformanceStatistic.java @@ -46,8 +46,8 @@ *

    * Some data are gathered only on system level for example write ahead log performance data or commit time {@link #getCommitTime()}. *

    - * This container may be used both for gathering information in single thread and in mutlithreading environment. Container itself is - * not thread safe, but it supports snapshoting of data. + * This container may be used both for gathering information in single thread and in multithreaded environment. Container itself is + * not thread safe, but it supports data snapshots. *

    * Every time when new data are gathered by container it checks whether minimum interval between two snapshots is passed and makes * data snapshot if needed, data snapshot can be used by aggregator which merges statistics from all containers together. Only last @@ -62,17 +62,17 @@ public class OSessionStoragePerformanceStatistic { /** * Amount of nanoseconds in second */ - private static final int NANOS_IN_SECOND = 1000000000; + private static final int NANOS_IN_SECOND = 1000000000; /** * Stack of time stamps which is used to init clock in startTimerXXX methods. */ - private final Deque timeStamps = new ArrayDeque(); + private final Deque timeStamps = new ArrayDeque<>(); /** * Stack of active components or in another words components which currently perform actions inside current thread. */ - private Deque componentsStack = new ArrayDeque(); + private final Deque componentsStack = new ArrayDeque<>(); /** * Container for performance counters of system performance as whole. @@ -80,83 +80,75 @@ public class OSessionStoragePerformanceStatistic { * Counters are put in separate class because each component also has given performance counters, so definition of counters on * component and system level is reused. */ - private final PerformanceCountersHolder performanceCountersHolder; + private final PerformanceCountersHolder performanceCountersHolder; /** * Object which is used to get current PC nano time. */ - private final NanoTimer nanoTimer; + private final NanoTimer nanoTimer; /** * Minimum interval in nanoseconds between two snapshots */ - private final long intervalBetweenSnapshots; + private final long intervalBetweenSnapshots; /** * Interval between two time series in nanoseconds. When this interval is passed, new attempt to make data snapshot will clear * performance statistic. -1 means that performance data will not be cleared. */ - private final long cleanUpInterval; + private final long cleanUpInterval; /** * Time stamp in nanoseconds when last snapshot is taken by container. */ - private long lastSnapshotTimestamp = -1; + private long lastSnapshotTimestamp = -1; /** * Time stamp in nanoseconds when data was cleaned up last time. */ - private long lastCleanUpTimeStamp = -1; + private long lastCleanUpTimeStamp = -1; /** * Snapshot of all data measured during session. */ - private volatile PerformanceSnapshot snapshot; + private volatile PerformanceSnapshot snapshot; /** * Map containing performance counters specific for concrete software component. */ - private Map countersByComponent = new HashMap(); + private final Map countersByComponent = new HashMap<>(); /** * Performance statistic gathered from write cache. It is lazy initialized to decrease memory consumption. */ - private WritCacheCountersHolder writCacheCountersHolder; + private WritCacheCountersHolder writCacheCountersHolder; /** * Storage performance characteristics. It is lazy initialized to decrease memory consumption. */ - private StorageCountersHolder storageCountersHolder; + private StorageCountersHolder storageCountersHolder; /** * Write ahead log performance characteristics. It is lazy initialized to decrease memory consumption. */ - private WALCountersHolder walCountersHolder; + private WALCountersHolder walCountersHolder; /** - * @param intervalBetweenSnapshots - * Minimum interval between two snapshots taken by container. - * @param cleanUpInterval - * Minimum interval between two time series, in other words container clears all statistic during next try of making - * snapshot after this interval is over. -1 means that data will not be cleared. + * @param intervalBetweenSnapshots Minimum interval between two snapshots taken by container. + * @param cleanUpInterval Minimum interval between two time series, in other words container clears all statistic during + * next try of making + * snapshot after this interval is over. -1 means that data will not be cleared. */ public OSessionStoragePerformanceStatistic(long intervalBetweenSnapshots, long cleanUpInterval) { - this(intervalBetweenSnapshots, new NanoTimer() { - @Override - public long getNano() { - return System.nanoTime(); - } - }, cleanUpInterval); + this(intervalBetweenSnapshots, System::nanoTime, cleanUpInterval); } /** - * @param nanoTimer - * Service to get current value of PC nano time. - * @param intervalBetweenSnapshots - * Minimum interval between two snapshots taken by container. - * @param cleanUpInterval - * Minimum interval between two time series, in other words container clears all statistic during next try of making - * snapshot after this interval is over. -1 means that data will not be cleared. + * @param nanoTimer Service to get current value of PC nano time. + * @param intervalBetweenSnapshots Minimum interval between two snapshots taken by container. + * @param cleanUpInterval Minimum interval between two time series, in other words container clears all statistic during + * next try of making + * snapshot after this interval is over. -1 means that data will not be cleared. */ public OSessionStoragePerformanceStatistic(long intervalBetweenSnapshots, NanoTimer nanoTimer, long cleanUpInterval) { this.nanoTimer = nanoTimer; @@ -174,9 +166,7 @@ public OSessionStoragePerformanceStatistic(long intervalBetweenSnapshots, NanoTi * Components can be stacked, so if components c1 and then c2 call this method than performance data for * both components at once started to be gathered. * - * @param componentName - * Name of component which started to perform operation on data. Name is case sensitive. - * @param type + * @param componentName Name of component which started to perform operation on data. Name is case sensitive. */ public void startComponentOperation(String componentName, ComponentType type) { final Component currentComponent = componentsStack.peek(); @@ -205,11 +195,8 @@ public void completeComponentOperation() { if (currentComponent.operationCount == 0) { final String componentName = currentComponent.name; - PerformanceCountersHolder cHolder = countersByComponent.get(componentName); - if (cHolder == null) { - cHolder = currentComponent.type.newCountersHolder(); - countersByComponent.put(componentName, cHolder); - } + PerformanceCountersHolder cHolder = countersByComponent + .computeIfAbsent(componentName, k -> currentComponent.type.newCountersHolder()); cHolder.operationsCount++; @@ -221,7 +208,7 @@ public void completeComponentOperation() { /** * @return Read speed of data in pages per second on cache level or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getReadSpeedFromCacheInPages() { return performanceCountersHolder.getReadSpeedFromCacheInPages(); @@ -232,10 +219,10 @@ public long getReadSpeedFromCacheInPages() { * is passed then value for whole system will be returned. If data for component with passed in name does not exist then * -1 will be returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Read speed of data in pages per second on cache level or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getReadSpeedFromCacheInPages(String componentName) { if (componentName == null) @@ -250,7 +237,7 @@ public long getReadSpeedFromCacheInPages(String componentName) { /** * @return Read speed of data from file system in pages per second or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getReadSpeedFromFileInPages() { return performanceCountersHolder.getReadSpeedFromFileInPages(); @@ -261,10 +248,10 @@ public long getReadSpeedFromFileInPages() { * then value for whole system will be returned. If data for component with passed in name does not exist then -1 * will be returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Read speed of data from file system in pages per second or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getReadSpeedFromFileInPages(String componentName) { if (componentName == null) @@ -289,8 +276,8 @@ public long getAmountOfPagesReadFromCache() { * for whole system will be returned. If data for component with passed in name does not exist then -1 will be * returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Amount of pages read from cache in total. */ public long getAmountOfPagesReadFromCache(String componentName) { @@ -316,8 +303,8 @@ public long getAmountOfPagesReadFromFile() { * for whole system will be returned. If data for component with passed in name does not exist then -1 will be * returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Amount of pages are read from file. */ public long getAmountOfPagesReadFromFile(String componentName) { @@ -333,7 +320,7 @@ public long getAmountOfPagesReadFromFile(String componentName) { /** * @return Write speed of data in pages per second on cache level or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getWriteSpeedInCacheInPages() { return performanceCountersHolder.getWriteSpeedInCacheInPages(); @@ -344,10 +331,10 @@ public long getWriteSpeedInCacheInPages() { * is passed then value for whole system will be returned. If data for component with passed in name does not exist then * -1 will be returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Write speed of data in pages per second on cache level or value which is less than 0, which means that value cannot be - * calculated. + * calculated. */ public long getWriteSpeedInCacheInPages(String componentName) { if (componentName == null) @@ -372,8 +359,8 @@ public long getAmountOfPagesWrittenInCache() { * for whole system will be returned. If data for component with passed in name does not exist then -1 will be * returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Amount of pages written to cache. */ public long getAmountOfPagesWrittenInCache(String componentName) { @@ -396,7 +383,7 @@ public PerformanceSnapshot getSnapshot() { /** * @return Average time of commit of atomic operation in nanoseconds or value which is less than 0, which means that value cannot - * be calculated. + * be calculated. */ public long getCommitTime() { return performanceCountersHolder.getCommitTime(); @@ -413,8 +400,8 @@ public int getCacheHits() { * Percent of cache hits for component name of which is passed as method argument. If null value is passed then value for whole * system will be returned. If data for component with passed in name does not exist then -1 will be returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Percent of cache hits or value which is less than 0, which means that value cannot be calculated. */ public int getCacheHits(String componentName) { @@ -433,10 +420,10 @@ public int getCacheHits(String componentName) { *

    * If null value is passed or data for component with passed in name does not exist then -1 will be returned. * - * @param componentName - * Name of component data of which should be returned. Name is case sensitive. + * @param componentName Name of component data of which should be returned. Name is case sensitive. + * * @return Average amount of pages which were read from cache for component with given name during single data operation or value - * which is less than 0, which means that value cannot be calculated. + * which is less than 0, which means that value cannot be calculated. */ public long getAmountOfPagesPerOperation(String componentName) { if (componentName == null) { @@ -454,8 +441,7 @@ public long getAmountOfPagesPerOperation(String componentName) { * Takes performance data are split by components from last snapshot and aggregates them with data passed inside method as * parameter. Result of aggregation of performance data is returned inside of passed in performance data. * - * @param counters - * Performance data for each component. + * @param counters Performance data for each component. */ public void pushComponentCounters(Map counters) { if (snapshot == null) @@ -464,11 +450,7 @@ public void pushComponentCounters(Map counter for (Map.Entry entry : snapshot.countersByComponent.entrySet()) { final String componentName = entry.getKey(); - PerformanceCountersHolder holder = counters.get(componentName); - if (holder == null) { - holder = entry.getValue().newInstance(); - counters.put(componentName, holder); - } + PerformanceCountersHolder holder = counters.computeIfAbsent(componentName, k -> entry.getValue().newInstance()); entry.getValue().pushData(holder); } @@ -478,8 +460,8 @@ public void pushComponentCounters(Map counter * Takes write cache performance data from last snapshot and aggregates them with data passed inside method as parameter. Result * of aggregation of performance data is returned inside of passed in performance data and as result of this method call. * - * @param holder - * Performance data for write cache may be null + * @param holder Performance data for write cache may be null + * * @return Result of aggregation of performance data */ public WritCacheCountersHolder pushWriteCacheCounters(WritCacheCountersHolder holder) { @@ -501,8 +483,8 @@ public WritCacheCountersHolder pushWriteCacheCounters(WritCacheCountersHolder ho * Takes storage performance data from last snapshot and aggregates them with data passed inside method as parameter. Result of * aggregation of performance data is returned inside of passed in performance data and as result of this method call. * - * @param holder - * Performance data for storage may be null + * @param holder Performance data for storage may be null + * * @return Result of aggregation of performance data */ public StorageCountersHolder pushStorageCounters(StorageCountersHolder holder) { @@ -524,8 +506,8 @@ public StorageCountersHolder pushStorageCounters(StorageCountersHolder holder) { * Takes write ahead log data from last snapshot and aggregates them with data passed inside method as parameter. Result of * aggregation of performance data is returned inside of passed in performance data and as result of this method call. * - * @param holder - * Performance data for write ahead log may be null + * @param holder Performance data for write ahead log may be null + * * @return Result of aggregation of performance data */ public WALCountersHolder pushWALCounters(WALCountersHolder holder) { @@ -547,8 +529,7 @@ public WALCountersHolder pushWALCounters(WALCountersHolder holder) { * Takes performance data for whole system from last snapshot and aggregates them with data passed inside method as parameter. * Result of aggregation of performance data is returned inside of passed in performance data. * - * @param holder - * Performance data for whole system. + * @param holder Performance data for whole system. */ public void pushSystemCounters(PerformanceCountersHolder holder) { if (snapshot == null) @@ -561,10 +542,8 @@ public void pushSystemCounters(PerformanceCountersHolder holder) { * Takes performance data for component from last snapshot and aggregates them with data passed inside method as parameter. Result * of aggregation of performance data is returned inside of passed in performance data. * - * @param name - * Name of component for which performance data are gathered. - * @param holder - * Performance data for given component. + * @param name Name of component for which performance data are gathered. + * @param holder Performance data for given component. */ public void pushComponentCounters(String name, PerformanceCountersHolder holder) { @@ -588,14 +567,14 @@ public void pushComponentCounters(String name, PerformanceCountersHolder holder) * Write ahead log performance data are stored inside of walData field. * * @return Performance characteristics of storage gathered after call of - * {@link OAbstractPaginatedStorage#startGatheringPerformanceStatisticForCurrentThread()} + * {@link OAbstractPaginatedStorage#startGatheringPerformanceStatisticForCurrentThread()} */ public ODocument toDocument() { final ODocument document = performanceCountersHolder.toDocument(); document.field("commitTime", getCommitTime(), OType.LONG); - final Map countersMap = new HashMap(); + final Map countersMap = new HashMap<>(); for (Map.Entry entry : countersByComponent.entrySet()) { countersMap.put(entry.getKey(), entry.getValue().toDocument()); } @@ -625,11 +604,8 @@ public void incrementPageAccessOnCacheLevel(boolean cacheHit) { for (Component component : componentsStack) { final String componentName = component.name; - PerformanceCountersHolder cHolder = countersByComponent.get(componentName); - if (cHolder == null) { - cHolder = component.type.newCountersHolder(); - countersByComponent.put(componentName, cHolder); - } + PerformanceCountersHolder cHolder = countersByComponent + .computeIfAbsent(componentName, k -> component.type.newCountersHolder()); cHolder.cacheAccessCount++; if (cacheHit) @@ -653,8 +629,7 @@ public void startPageReadFromFileTimer() { * {@link #startComponentOperation(String, ComponentType)} method before the call and {@link #completeComponentOperation()} after * the call. * - * @param readPages - * Amount of pages which were read by single call to file system. + * @param readPages Amount of pages which were read by single call to file system. */ public void stopPageReadFromFileTimer(int readPages) { final long endTs = nanoTimer.getNano(); @@ -666,11 +641,8 @@ public void stopPageReadFromFileTimer(int readPages) { for (Component component : componentsStack) { final String componentName = component.name; - PerformanceCountersHolder cHolder = countersByComponent.get(componentName); - if (cHolder == null) { - cHolder = component.type.newCountersHolder(); - countersByComponent.put(componentName, cHolder); - } + PerformanceCountersHolder cHolder = countersByComponent + .computeIfAbsent(componentName, k -> component.type.newCountersHolder()); cHolder.pageReadFromFileTime += timeDiff; cHolder.pageReadFromFileCount += readPages; } @@ -697,8 +669,7 @@ public void startWriteCacheFlushTimer() { /** * Stops and records results of timer which counts how much time was spent on operation of flush pages in write cache. * - * @param pagesFlushed - * Amount of pages were flushed during this operation. + * @param pagesFlushed Amount of pages were flushed during this operation. */ public void stopWriteCacheFlushTimer(int pagesFlushed) { // lazy initialization to prevent memory consumption @@ -769,11 +740,8 @@ public void stopPageReadFromCacheTimer() { for (Component component : componentsStack) { final String componentName = component.name; - PerformanceCountersHolder cHolder = countersByComponent.get(componentName); - if (cHolder == null) { - cHolder = component.type.newCountersHolder(); - countersByComponent.put(componentName, cHolder); - } + PerformanceCountersHolder cHolder = countersByComponent + .computeIfAbsent(componentName, k -> component.type.newCountersHolder()); cHolder.pageReadFromCacheTime += timeDiff; cHolder.pageReadFromCacheCount++; @@ -837,11 +805,8 @@ public void stopPageWriteInCacheTimer() { for (Component component : componentsStack) { final String componentName = component.name; - PerformanceCountersHolder cHolder = countersByComponent.get(componentName); - if (cHolder == null) { - cHolder = component.type.newCountersHolder(); - countersByComponent.put(componentName, cHolder); - } + PerformanceCountersHolder cHolder = countersByComponent + .computeIfAbsent(componentName, k -> component.type.newCountersHolder()); cHolder.pageWriteToCacheTime += timeDiff; cHolder.pageWriteToCacheCount++; @@ -1144,10 +1109,8 @@ public void startWALLogRecordTimer() { /** * Stops and records results of timer which counts how much time was spent on logging of single write ahead log record. * - * @param isStartRecord - * Indicates whether we logged "start atomic operation" record - * @param isStopRecord - * Indicates whether we logged "stop atomic operation" record + * @param isStartRecord Indicates whether we logged "start atomic operation" record + * @param isStopRecord Indicates whether we logged "stop atomic operation" record */ public void stopWALRecordTimer(boolean isStartRecord, boolean isStopRecord) { final long endTs = nanoTimer.getNano(); @@ -1201,8 +1164,7 @@ private void checkComponentType(Component component, ComponentType expected) { /** * Makes snapshot of data if time for next snapshot is passed. Also clear all data if {@link #cleanUpInterval} interval is over. * - * @param currentTime - * Time of last measurement in nanoseconds or -1 if time is unknown + * @param currentTime Time of last measurement in nanoseconds or -1 if time is unknown */ private void makeSnapshotIfNeeded(long currentTime) { if (currentTime < 0) { @@ -1258,7 +1220,7 @@ private static final class Component { private final String name; private final ComponentType type; - private int operationCount; + private int operationCount; Component(String name, ComponentType type) { this.name = name; @@ -1274,20 +1236,17 @@ public enum ComponentType { PerformanceCountersHolder newCountersHolder() { return new PerformanceCountersHolder(); } - }, - INDEX { + }, INDEX { @Override IndexCountersHolder newCountersHolder() { return new IndexCountersHolder(); } - }, - CLUSTER { + }, CLUSTER { @Override OClusterCountersHolder newCountersHolder() { return new OClusterCountersHolder(); } - }, - RIDBAG { + }, RIDBAG { @Override RidbagCountersHolder newCountersHolder() { return new RidbagCountersHolder(); @@ -1503,7 +1462,7 @@ public void pushData(WritCacheCountersHolder holder) { /** * @return Average amount of pages which are flushed during "page flush" operation of write cache or -1 if value is - * undefined + * undefined */ public long getPagesPerFlush() { if (flushOperationsCount == 0) @@ -1514,7 +1473,7 @@ public long getPagesPerFlush() { /** * @return Average amount of time which is spent on each "page flush" operation of write cache or -1 if value is - * undefined. + * undefined. */ public long getFlushOperationsTime() { if (flushOperationsCount == 0) @@ -1545,6 +1504,7 @@ public ODocument toDocument() { } } + @SuppressWarnings("unused") public static class IndexCountersHolder extends PerformanceCountersHolder { private long updatedEntries; private long timeUpdateEntry; @@ -1563,6 +1523,7 @@ public static class IndexCountersHolder extends PerformanceCountersHolder { private long readEntries; private long timeReadEntry; private long readEntryPages; + private long readEntryFilePages; private long readEntryPageTime; private long readEntryFilePageTime; @@ -1707,6 +1668,7 @@ void incrementOperationsCounter(int pages, int filePages) { } } + @SuppressWarnings("unused") public static class RidbagCountersHolder extends PerformanceCountersHolder { private long updatedEntries; private long timeUpdateEntry; @@ -1867,63 +1829,65 @@ public static class PerformanceCountersHolder implements CountersHolder countersByComponent; @@ -2090,7 +2055,7 @@ public final static class PerformanceSnapshot { performanceCountersHolder.pushData(this.performanceCountersHolder); // to preserve thread safety we assign map instance to the final field when it is completely filled by data - Map counters = new HashMap(); + Map counters = new HashMap<>(); for (Map.Entry entry : countersByComponent.entrySet()) { final PerformanceCountersHolder holder = entry.getValue().newInstance(); entry.getValue().pushData(holder); @@ -2130,8 +2095,7 @@ public final static class PerformanceSnapshot { /** * Common interface which should implement all classes which contain system/component performance data. * - * @param - * Real component class + * @param Real component class */ public interface CountersHolder { /** @@ -2141,8 +2105,6 @@ public interface CountersHolder { /** * Accumulates data in current and passed in containers and push data back to passed in container. - * - * @param holder */ void pushData(T holder); diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryOnlyDiskCache.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryOnlyDiskCache.java index d8f3d8223b8..9e16ee93f64 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryOnlyDiskCache.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryOnlyDiskCache.java @@ -655,7 +655,7 @@ public OLogSequenceNumber getMinimalNotFlushedLSN() { } @Override - public void updateDirtyPagesTable(OCachePointer pointer) throws IOException { + public void updateDirtyPagesTable(OCachePointer pointer) { } @Override @@ -723,7 +723,7 @@ public String restoreFileById(long fileId) throws IOException { } @Override - public void closeFile(long fileId, boolean flush, OWriteCache writeCache) throws IOException { + public void closeFile(long fileId, boolean flush, OWriteCache writeCache) { close(fileId, flush); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryStorage.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryStorage.java index 9bbcf2636b5..7ca82981a66 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryStorage.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/memory/ODirectMemoryStorage.java @@ -96,7 +96,7 @@ public String getURL() { } @Override - public void makeFullCheckpoint() throws IOException { + public void makeFullCheckpoint() { } @Override diff --git a/core/src/test/java/com/orientechnologies/orient/core/PostponedEngineStartTest.java b/core/src/test/java/com/orientechnologies/orient/core/PostponedEngineStartTest.java index fd917a971ca..b0138141ea4 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/PostponedEngineStartTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/PostponedEngineStartTest.java @@ -358,12 +358,12 @@ public Collection getClusterInstances() { } @Override - public int addCluster(String iClusterName, boolean forceListBased, Object... iParameters) { + public int addCluster(String iClusterName, Object... iParameters) { return 0; } @Override - public int addCluster(String iClusterName, int iRequestedId, boolean forceListBased, Object... iParameters) { + public int addCluster(String iClusterName, int iRequestedId, Object... iParameters) { return 0; } diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/ODropClusterStatementExecutionTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/ODropClusterStatementExecutionTest.java old mode 100644 new mode 100755 index 64f6e486ec7..bbc34be6fa9 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/ODropClusterStatementExecutionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/ODropClusterStatementExecutionTest.java @@ -29,7 +29,7 @@ public class ODropClusterStatementExecutionTest { @Test public void testPlain() { String cluster = "testPlain"; - ((ODatabaseDocumentTx) db).getStorage().addCluster(cluster, false); + ((ODatabaseDocumentTx) db).getStorage().addCluster(cluster); Assert.assertTrue(db.getClusterIdByName(cluster) > 0); OResultSet result = db.command("drop cluster " + cluster); @@ -45,7 +45,7 @@ public class ODropClusterStatementExecutionTest { @Test public void testDropClusterIfExists() { String cluster = "testDropClusterIfExists"; - ((ODatabaseDocumentTx) db).getStorage().addCluster(cluster, false); + ((ODatabaseDocumentTx) db).getStorage().addCluster(cluster); Assert.assertTrue(db.getClusterIdByName(cluster) > 0); OResultSet result = db.command("drop cluster " + cluster+" IF EXISTS"); diff --git a/core/src/test/java/com/orientechnologies/orient/core/storage/StorageNamingTests.java b/core/src/test/java/com/orientechnologies/orient/core/storage/StorageNamingTests.java index cf716bff171..6cfe9aaef03 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/storage/StorageNamingTests.java +++ b/core/src/test/java/com/orientechnologies/orient/core/storage/StorageNamingTests.java @@ -34,7 +34,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.IllegalCharsetNameException; import java.util.Collection; import java.util.List; import java.util.Map; @@ -178,12 +177,12 @@ public Collection getClusterInstances() { } @Override - public int addCluster(String iClusterName, boolean forceListBased, Object... iParameters) { + public int addCluster(String iClusterName, Object... iParameters) { return 0; } @Override - public int addCluster(String iClusterName, int iRequestedId, boolean forceListBased, Object... iParameters) { + public int addCluster(String iClusterName, int iRequestedId, Object... iParameters) { return 0; } diff --git a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java index 50cf852a099..e5ebfdcf057 100755 --- a/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java +++ b/distributed/src/main/java/com/orientechnologies/orient/server/distributed/impl/ODistributedStorage.java @@ -1564,7 +1564,7 @@ public Collection getClusterInstances() { } @Override - public int addCluster(final String iClusterName, boolean forceListBased, final Object... iParameters) { + public int addCluster(final String iClusterName, final Object... iParameters) { for (int retry = 0; retry < 10; ++retry) { final AtomicInteger clId = new AtomicInteger(); @@ -1582,7 +1582,7 @@ public int addCluster(final String iClusterName, boolean forceListBased, final O new OCallable() { @Override public Object call(OModifiableDistributedConfiguration iArgument) { - clId.set(wrapped.addCluster(iClusterName, false, iParameters)); + clId.set(wrapped.addCluster(iClusterName, iParameters)); final OCommandSQL commandSQL = new OCommandSQL(cmd.toString()); commandSQL.addExcludedNode(getNodeId()); @@ -1626,7 +1626,7 @@ public Object call(OModifiableDistributedConfiguration iArgument) { continue; } } else - clId.set(wrapped.addCluster(iClusterName, false, iParameters)); + clId.set(wrapped.addCluster(iClusterName, iParameters)); return clId.get(); } @@ -1636,8 +1636,8 @@ public Object call(OModifiableDistributedConfiguration iArgument) { } @Override - public int addCluster(String iClusterName, int iRequestedId, boolean forceListBased, Object... iParameters) { - return wrapped.addCluster(iClusterName, iRequestedId, forceListBased, iParameters); + public int addCluster(String iClusterName, int iRequestedId, Object... iParameters) { + return wrapped.addCluster(iClusterName, iRequestedId, iParameters); } public boolean dropCluster(final String iClusterName, final boolean iTruncate) {