Skip to content

Commit

Permalink
enabled operator wrap in check style and fixed relative issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Jun 21, 2019
1 parent d510b54 commit 9ec7147
Show file tree
Hide file tree
Showing 52 changed files with 576 additions and 406 deletions.
2 changes: 0 additions & 2 deletions _base/orient_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,10 @@
</module>
-->
<module name="MethodParamPad"/>
<!--
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
-->
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,9 @@ public void handleException(Throwable throwable) {
throw new OResponseProcessingException("Exception during response processing", (Throwable) throwable);
} else {
// WRAP IT
String exceptionType = throwable != null ? throwable.getClass().getName() : "null";
OLogManager.instance().error(this,
"Error during exception serialization, serialized exception is not Throwable, exception type is " + (throwable != null ?
throwable.getClass().getName() :
"null"), null);
"Error during exception serialization, serialized exception is not Throwable, exception type is " + exceptionType, null);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
* Abstract implementation of binary channel.
*/
public abstract class OChannelBinaryClientAbstract extends OChannelBinary {
protected final int socketTimeout; // IN MS
protected final short srvProtocolVersion;
protected String serverURL;
protected byte currentStatus;
protected int currentSessionId;
protected final int socketTimeout; // IN MS
protected final short srvProtocolVersion;
protected String serverURL;
protected byte currentStatus;
protected int currentSessionId;

public OChannelBinaryClientAbstract(final String remoteHost, final int remotePort, final String iDatabaseName,
final OContextConfiguration iConfig, final int protocolVersion) throws IOException {
Expand Down Expand Up @@ -157,7 +157,7 @@ public void clearInput() throws IOException {

/**
* Tells if the channel is connected.
*
*
* @return true if it's connected, otherwise false.
*/
public boolean isConnected() {
Expand All @@ -167,7 +167,6 @@ public boolean isConnected() {

/**
* Gets the major supported protocol version
*
*/
public short getSrvProtocolVersion() {
return srvProtocolVersion;
Expand Down Expand Up @@ -268,10 +267,10 @@ protected void throwSerializedException(final byte[] serializedException) throws
throw new OResponseProcessingException("Exception during response processing", (Throwable) throwable);
}
// WRAP IT
else
else {
String exceptionType = throwable != null ? throwable.getClass().getName() : "null";
OLogManager.instance().error(this,
"Error during exception serialization, serialized exception is not Throwable, exception type is " + (throwable != null ?
throwable.getClass().getName() :
"null"), null);
"Error during exception serialization, serialized exception is not Throwable, exception type is " + exceptionType, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1679,12 +1679,19 @@ protected String addHost(String host) {
host = host.substring(0, host.indexOf("/"));

// REGISTER THE REMOTE SERVER+PORT
if (!host.contains(":"))
host += ":" + (clientConfiguration.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL) ?
getDefaultSSLPort() :
getDefaultPort());
else if (host.split(":").length < 2 || host.split(":")[1].trim().length() == 0)
host += (clientConfiguration.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL) ? getDefaultSSLPort() : getDefaultPort());
if (!host.contains(":")) {
if (clientConfiguration.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL)) {
host += ":" + getDefaultSSLPort();
} else {
host += ":" + getDefaultPort();
}
} else if (host.split(":").length < 2 || host.split(":")[1].trim().length() == 0) {
if (clientConfiguration.getValueAsBoolean(OGlobalConfiguration.CLIENT_USE_SSL)) {
host += getDefaultSSLPort();
} else {
host += getDefaultPort();
}
}

// DISABLED BECAUSE THIS DID NOT ALLOW TO CONNECT TO LOCAL HOST ANYMORE IF THE SERVER IS BOUND TO 127.0.0.1
// CONVERT 127.0.0.1 TO THE PUBLIC IP IF POSSIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ else if (iObject instanceof Set<?>) {
return Array.get(iObject, iIndex);
else if (iObject instanceof Iterator<?> || iObject instanceof Iterable<?>) {

final Iterator<Object> it = (iObject instanceof Iterable<?>) ?
((Iterable<Object>) iObject).iterator() :
(Iterator<Object>) iObject;
final Iterator<Object> it;
if (iObject instanceof Iterable<?>)
it = ((Iterable<Object>) iObject).iterator();
else
it = (Iterator<Object>) iObject;
for (int i = 0; it.hasNext(); ++i) {
final Object o = it.next();
if (i == iIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ protected T getImmutableResourceId(final T iResourceId) {
}

private static int defaultConcurrency() {
return (Runtime.getRuntime().availableProcessors() << 6) > DEFAULT_CONCURRENCY_LEVEL ?
(Runtime.getRuntime().availableProcessors() << 6) :
DEFAULT_CONCURRENCY_LEVEL;
if ((Runtime.getRuntime().availableProcessors() << 6) > DEFAULT_CONCURRENCY_LEVEL)
return Runtime.getRuntime().availableProcessors() << 6;
else
return DEFAULT_CONCURRENCY_LEVEL;
}

private static int closestInteger(int value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,65 @@ else if (h.startsWith("db.") && h.endsWith("txRollback"))
}
}

long lastCreateRecordsSec = lastCreateRecords == 0 ?
msFromLastDump < 1000 ? 1 : 0 :
(lastCreateRecords - statsCreateRecords) / (msFromLastDump / 1000);
long lastReadRecordsSec =
lastReadRecords == 0 ? 0 : msFromLastDump < 1000 ? 1 : (lastReadRecords - statsReadRecords) / (msFromLastDump / 1000);
long lastUpdateRecordsSec = lastUpdateRecords == 0 || msFromLastDump < 1000 ?
0 :
(lastUpdateRecords - statsUpdateRecords) / (msFromLastDump / 1000);
long lastDeleteRecordsSec = lastDeleteRecords == 0 ?
0 :
msFromLastDump < 1000 ? 1 : (lastDeleteRecords - statsDeleteRecords) / (msFromLastDump / 1000);
long lastCommandsSec =
lastCommands == 0 ? 0 : msFromLastDump < 1000 ? 1 : (lastCommands - statsCommands) / (msFromLastDump / 1000);
long lastTxCommitSec =
lastTxCommit == 0 ? 0 : msFromLastDump < 1000 ? 1 : (lastTxCommit - statsTxCommit) / (msFromLastDump / 1000);
long lastTxRollbackSec =
lastTxRollback == 0 ? 0 : msFromLastDump < 1000 ? 1 : (lastTxRollback - statsTxRollback) / (msFromLastDump / 1000);
long lastCreateRecordsSec;
if (lastCreateRecords == 0) {
lastCreateRecordsSec = msFromLastDump < 1000 ? 1 : 0;
} else {
lastCreateRecordsSec = (lastCreateRecords - statsCreateRecords) / (msFromLastDump / 1000);
}

long lastReadRecordsSec;
if (msFromLastDump < 1000) {
lastReadRecordsSec = lastReadRecords == 0 ? 0 : 1;
} else if (lastReadRecords == 0) {
lastReadRecordsSec = 0;
} else {
lastReadRecordsSec = (lastReadRecords - statsReadRecords) / (msFromLastDump / 1000);
}

long lastUpdateRecordsSec;
if (lastUpdateRecords == 0 || msFromLastDump < 1000) {
lastUpdateRecordsSec = 0;
} else {
lastUpdateRecordsSec = (lastUpdateRecords - statsUpdateRecords) / (msFromLastDump / 1000);
}

long lastDeleteRecordsSec;
if (lastDeleteRecords == 0) {
lastDeleteRecordsSec = 0;
} else if (msFromLastDump < 1000) {
lastDeleteRecordsSec = 1;
} else {
lastDeleteRecordsSec = (lastDeleteRecords - statsDeleteRecords) / (msFromLastDump / 1000);
}

long lastCommandsSec;
if (lastCommands == 0) {
lastCommandsSec = 0;
} else if (msFromLastDump < 1000) {
lastCommandsSec = 1;
} else {
lastCommandsSec = (lastCommands - statsCommands) / (msFromLastDump / 1000);
}

long lastTxCommitSec;
if (lastTxCommit == 0) {
lastTxCommitSec = 0;
} else if (msFromLastDump < 1000) {
lastTxCommitSec = 1;
} else {
lastTxCommitSec = (lastTxCommit - statsTxCommit) / (msFromLastDump / 1000);
}

long lastTxRollbackSec;
if (lastTxRollback == 0) {
lastTxRollbackSec = 0;
} else if (msFromLastDump < 1000) {
lastTxRollbackSec = 1;
} else {
lastTxRollbackSec = (lastTxRollback - statsTxRollback) / (msFromLastDump / 1000);

}

buffer.append(String.format(
"\nCRUD: C(%d %d/sec) R(%d %d/sec) U(%d %d/sec) D(%d %d/sec) - COMMANDS (%d %d/sec) - TX: COMMIT(%d %d/sec) ROLLBACK(%d %d/sec)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2395,57 +2395,6 @@ public static Object executeWithRetries(final OCallable<Object, Integer> callbac
throw lastException;
}

private void bindPropertiesToContext(OContextConfiguration configuration, final Map<String, Object> iProperties) {
final String connectionStrategy = iProperties != null ? (String) iProperties.get("connectionStrategy") : null;
if (connectionStrategy != null)
configuration.setValue(OGlobalConfiguration.CLIENT_CONNECTION_STRATEGY, connectionStrategy);

final String compressionMethod = iProperties != null ?
(String) iProperties.get(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getKey().toLowerCase(Locale.ENGLISH)) :
null;
if (compressionMethod != null)
// SAVE COMPRESSION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, compressionMethod);

final String encryptionMethod = iProperties != null ?
(String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getKey().toLowerCase(Locale.ENGLISH)) :
null;
if (encryptionMethod != null)
// SAVE ENCRYPTION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD, encryptionMethod);

final String encryptionKey = iProperties != null ?
(String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey().toLowerCase(Locale.ENGLISH)) :
null;
if (encryptionKey != null)
// SAVE ENCRYPTION KEY IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, encryptionKey);
}

private void bindPropertiesToContextGlobal(OContextConfiguration configuration,
final Map<OGlobalConfiguration, Object> iProperties) {
final String connectionStrategy = iProperties != null ? (String) iProperties.get("connectionStrategy") : null;
if (connectionStrategy != null)
configuration.setValue(OGlobalConfiguration.CLIENT_CONNECTION_STRATEGY, connectionStrategy);

final String compressionMethod =
iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD) : null;
if (compressionMethod != null)
// SAVE COMPRESSION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, compressionMethod);

final String encryptionMethod =
iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD) : null;
if (encryptionMethod != null)
// SAVE ENCRYPTION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD, encryptionMethod);

final String encryptionKey = iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY) : null;
if (encryptionKey != null)
// SAVE ENCRYPTION KEY IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, encryptionKey);
}

public boolean isUseLightweightEdges() {
final List<OStorageEntryConfiguration> custom = (List<OStorageEntryConfiguration>) this.get(ATTRIBUTES.CUSTOM);
for (OStorageEntryConfiguration c : custom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,12 @@ private static Object checkClzAttribute(final ODocument iDocument, String attr,
} else {
final Object funcProp = iDocument.field(attr);
if (funcProp != null) {
final String funcName = funcProp instanceof ODocument ?
(String) ((ODocument) funcProp).field("name") :
funcProp.toString();
final String funcName;
if (funcProp instanceof ODocument) {
funcName = ((ODocument) funcProp).field("name");
} else {
funcName = funcProp.toString();
}
func = database.getMetadata().getFunctionLibrary().getFunction(funcName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class OImmutableClass implements OClass {
@Deprecated
public static final String VERTEX_CLASS_NAME = OClass.VERTEX_CLASS_NAME;

private boolean inited = false;
private boolean inited = false;
private final boolean isAbstract;
private final boolean strictMode;
private final String name;
Expand Down Expand Up @@ -159,9 +159,11 @@ public void init() {
getRawIndexes(indexes);

final ODatabaseDocumentInternal db = getDatabase();
this.autoShardingIndex = db != null && db.getMetadata() != null && db.getMetadata().getIndexManager() != null ?
db.getMetadata().getIndexManager().getClassAutoShardingIndex(name) :
null;
if (db != null && db.getMetadata() != null && db.getMetadata().getIndexManager() != null) {
this.autoShardingIndex = db.getMetadata().getIndexManager().getClassAutoShardingIndex(name);
} else {
this.autoShardingIndex = null;
}
}

inited = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,11 @@ public void fromStream() {
regexp = (String) (document.containsField("regexp") ? document.field("regexp") : null);
linkedClassName = (String) (document.containsField("linkedClass") ? document.field("linkedClass") : null);
linkedType = document.field("linkedType") != null ? OType.getById(((Integer) document.field("linkedType")).byteValue()) : null;
customFields = (Map<String, String>) (document.containsField("customFields") ?
document.field("customFields", OType.EMBEDDEDMAP) :
null);
if (document.containsField("customFields")) {
customFields = document.field("customFields", OType.EMBEDDEDMAP);
} else {
customFields = null;
}
description = (String) (document.containsField("description") ? document.field("description") : null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,12 @@ else if (Character.isDigit(indexAsString.charAt(0)))
String to = indexRanges.get(1);

final int rangeFrom = from != null && !from.isEmpty() ? Integer.parseInt(from) : 0;
final int rangeTo = to != null && !to.isEmpty() ?
Math.min(Integer.parseInt(to), OMultiValue.getSize(value) - 1) :
OMultiValue.getSize(value) - 1;
final int rangeTo;
if (to != null && !to.isEmpty()) {
rangeTo = Math.min(Integer.parseInt(to), OMultiValue.getSize(value) - 1);
} else {
rangeTo = OMultiValue.getSize(value) - 1;
}

int arraySize = rangeTo - rangeFrom + 1;
if (arraySize < 0) {
Expand Down
Loading

0 comments on commit 9ec7147

Please sign in to comment.