Skip to content

Commit

Permalink
Issue #7540 was implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Sep 8, 2017
1 parent 1310764 commit 221d340
Show file tree
Hide file tree
Showing 17 changed files with 633 additions and 241 deletions.
14 changes: 6 additions & 8 deletions core/src/main/java/com/orientechnologies/orient/core/config/OContextConfiguration.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
/**
* Represents a context configuration where custom setting could be defined for the context only. If not defined, globals will be
* taken.
*
*
* @author Luca Garulli (l.garulli--(at)--orientdb.com)
*
*/
public class OContextConfiguration implements Serializable {
private final Map<String, Object> config = new ConcurrentHashMap<String, Object>();
Expand All @@ -41,9 +40,8 @@ public OContextConfiguration() {

/**
* Initializes the context with custom parameters.
*
* @param iConfig
* Map of parameters of type Map<String, Object>.
*
* @param iConfig Map of parameters of type Map<String, Object>.
*/
public OContextConfiguration(final Map<String, Object> iConfig) {
this.config.putAll(iConfig);
Expand All @@ -68,9 +66,9 @@ public Object setValue(final String iName, final Object iValue) {
return config.put(iName, iValue);
}

public Object getValue(final OGlobalConfiguration iConfig) {
public <T> T getValue(final OGlobalConfiguration iConfig) {
if (config != null && config.containsKey(iConfig.getKey()))
return config.get(iConfig.getKey());
return (T) config.get(iConfig.getKey());
return iConfig.getValue();
}

Expand All @@ -88,7 +86,7 @@ public <T> T getValue(final String iName, final T iDefaultValue) {

public boolean getValueAsBoolean(final OGlobalConfiguration iConfig) {
final Object v = getValue(iConfig);
if( v == null )
if (v == null)
return false;
return v instanceof Boolean ? ((Boolean) v).booleanValue() : Boolean.parseBoolean(v.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ public void change(Object currentValue, Object newValue) {
STORAGE_CHECKSUM_MODE("storage.diskCache.checksumMode", "Controls the per-page checksum storage and verification done by "
+ "the file cache. Possible modes: 'off' – checksums are completely off; 'store' – checksums are calculated and stored "
+ "on page flushes, no verification is done on page loads, stored checksums are verified only during user-initiated health "
+ "checks; 'storeAndVerify' (default) – checksums are calculated and stored on page flushes, verification is performed on "
+ "checks; 'storeAndVerify' – checksums are calculated and stored on page flushes, verification is performed on "
+ "each page load, errors are reported in the log; 'storeAndThrow' – same as `storeAndVerify` with addition of exceptions "
+ "thrown on errors, this mode is useful for debugging and testing, but should be avoided in a production environment.",
OChecksumMode.class, OChecksumMode.StoreAndVerify, false),
+ "thrown on errors, this mode is useful for debugging and testing, but should be avoided in a production environment;"
+ " 'storeAndSwitchReadOnlyMode' (default) - Same as 'storeAndVerify' with addition that storage will be switched in read only mode "
+ "till it will not be repaired.", OChecksumMode.class, OChecksumMode.StoreAndSwitchReadOnlyMode, false),

@Deprecated STORAGE_CONFIGURATION_SYNC_ON_UPDATE("storage.configuration.syncOnUpdate",
"Indicates a force sync should be performed for each update on the storage configuration", Boolean.class, true),
Expand Down Expand Up @@ -802,7 +803,7 @@ public void change(final Object iCurrentValue, final Object iNewValue) {
/**
* @Since 2.2.0
*/
@OApi(maturity = OApi.MATURITY.NEW)DISTRIBUTED_DB_WORKERTHREADS("distributed.dbWorkerThreads",
@OApi(maturity = OApi.MATURITY.NEW) DISTRIBUTED_DB_WORKERTHREADS("distributed.dbWorkerThreads",
"Number of parallel worker threads per database that process distributed messages. Use 0 for automatic", Integer.class, 0),

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.orientechnologies.orient.core.exception;

import com.orientechnologies.common.exception.OHighLevelException;

/**
* Exception which is thrown by storage when it detects that some pages of files are broken and it switches to "read only" mode.
*/
public class OPageIsBrokenException extends OStorageException implements OHighLevelException {
@SuppressWarnings("unused")
public OPageIsBrokenException(OStorageException exception) {
super(exception);
}

public OPageIsBrokenException(String string) {
super(string);
}
}
8 changes: 7 additions & 1 deletion core/src/main/java/com/orientechnologies/orient/core/storage/OChecksumMode.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public enum OChecksumMode {
* Same as {@link OChecksumMode#StoreAndVerify} with addition of exceptions thrown on errors. This mode is useful for debugging
* and testing, but should be avoided in a production environment.
*/
StoreAndThrow
StoreAndThrow,

/**
* Same as {@link OChecksumMode#StoreAndVerify} with addition that storage will be switched in read only mode
* till it will not be repaired.
*/
StoreAndSwitchReadOnlyMode

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.orientechnologies.orient.core.command.OCommandOutputListener;
import com.orientechnologies.orient.core.storage.cache.local.OBackgroundExceptionListener;
import com.orientechnologies.orient.core.storage.impl.local.OLowDiskSpaceListener;
import com.orientechnologies.orient.core.storage.impl.local.OPageIsBrokenListener;
import com.orientechnologies.orient.core.storage.impl.local.paginated.wal.OLogSequenceNumber;
import com.orientechnologies.orient.core.storage.impl.local.statistic.OPerformanceStatisticManager;

Expand All @@ -33,6 +34,17 @@
import java.util.concurrent.CountDownLatch;

public interface OWriteCache {
/**
* Adds listener which is called by cache if corruption of file page is detected.
*/
void addPageIsBrokenListener(OPageIsBrokenListener listener);

/**
* Removes listener which is called by cache if corruption of file page is detected.
*/
@SuppressWarnings("unused")
void removePageIsBrokenListener(OPageIsBrokenListener listener);

void addLowDiskSpaceListener(OLowDiskSpaceListener listener);

void removeLowDiskSpaceListener(OLowDiskSpaceListener listener);
Expand Down Expand Up @@ -131,8 +143,6 @@ OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boolean ad

Map<String, Long> files();

int pageSize();

/**
* Finds if there was file in write cache with given id which is deleted right now.
* If such file exists it creates new file with the same name at it was in deleted file.
Expand All @@ -143,8 +153,6 @@ OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boolean ad
*/
String restoreFileById(long fileId) throws IOException;

boolean fileIdsAreEqual(long firsId, long secondId);

/**
* Adds listener which is triggered if exception is cast inside background flush data thread.
*
Expand Down
Loading

0 comments on commit 221d340

Please sign in to comment.