diff --git a/_base/base-build.xml b/_base/base-build.xml
index 099d5b53b3c..7a32fd85738 100644
--- a/_base/base-build.xml
+++ b/_base/base-build.xml
@@ -13,6 +13,9 @@
+
+
+
diff --git a/build.xml b/build.xml
index ffbd5549158..b79149bb5b4 100644
--- a/build.xml
+++ b/build.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/client/pom.xml b/client/pom.xml
index 3ca216179c7..fecbaf876fc 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -24,7 +24,7 @@
com.orientechnologies
orientdb-parent
- 1.6.1
+ 1.6.2
../
@@ -35,7 +35,6 @@
*
com.orientechnologies.orient.client.*
- com.orientechnologies.orientdb-core
@@ -46,5 +45,4 @@
-
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 08f3d619fc6..bd8e1debde0 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
@@ -1809,13 +1809,15 @@ private void removeDeadConnections() {
// FREE DEAD CONNECTIONS
int removedDeadConnections = 0;
for (OChannelBinaryAsynchClient n : new ArrayList(networkPool)) {
- if (n != null && !n.isConnected())
+ if (n != null && !n.isConnected()) //Fixed issue with removing of network connections though connection is active.
+ {
try {
n.close();
} catch (Exception e) {
}
networkPool.remove(n);
removedDeadConnections++;
+ }
}
OLogManager.instance().debug(this, "Found and removed %d dead connections from the network pool", removedDeadConnections);
diff --git a/commons/pom.xml b/commons/pom.xml
index 5a59215c284..cc7544565c4 100644
--- a/commons/pom.xml
+++ b/commons/pom.xml
@@ -24,7 +24,7 @@
com.orientechnologies
orientdb-parent
- 1.6.1
+ 1.6.2
../
@@ -35,7 +35,6 @@
com.orientechnologies.common.*
javax.imageio.spi.*,sun.misc.*;resolution:=optional
- com.orientechnologies.orientdb-core
diff --git a/commons/src/main/java/com/orientechnologies/common/comparator/OCaseInsentiveComparator.java b/commons/src/main/java/com/orientechnologies/common/comparator/OCaseInsentiveComparator.java
index 0011959b41a..91980311037 100644
--- a/commons/src/main/java/com/orientechnologies/common/comparator/OCaseInsentiveComparator.java
+++ b/commons/src/main/java/com/orientechnologies/common/comparator/OCaseInsentiveComparator.java
@@ -7,6 +7,6 @@
*/
public class OCaseInsentiveComparator implements Comparator {
public int compare(final String stringOne, final String stringTwo) {
- return stringOne.toLowerCase().compareTo(stringTwo.toLowerCase());
+ return stringOne.compareToIgnoreCase(stringTwo);
}
}
diff --git a/commons/src/main/java/com/orientechnologies/common/console/OCommandStream.java b/commons/src/main/java/com/orientechnologies/common/console/OCommandStream.java
new file mode 100755
index 00000000000..7d4cead2488
--- /dev/null
+++ b/commons/src/main/java/com/orientechnologies/common/console/OCommandStream.java
@@ -0,0 +1,11 @@
+package com.orientechnologies.common.console;
+
+import com.orientechnologies.common.concur.resource.OCloseable;
+
+/**
+ * @author Artem Orobets
+ */
+public interface OCommandStream extends OCloseable {
+ boolean hasNext();
+ String nextCommand();
+}
diff --git a/commons/src/main/java/com/orientechnologies/common/console/OConsoleApplication.java b/commons/src/main/java/com/orientechnologies/common/console/OConsoleApplication.java
old mode 100644
new mode 100755
index 3f0d8735dd2..874eac0458e
--- a/commons/src/main/java/com/orientechnologies/common/console/OConsoleApplication.java
+++ b/commons/src/main/java/com/orientechnologies/common/console/OConsoleApplication.java
@@ -22,8 +22,14 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -85,7 +91,7 @@ public int run() {
if (consoleInput == null || consoleInput.length() == 0)
continue;
- if (!executeCommands(new Scanner(consoleInput), false))
+ if (!executeCommands(new ODFACommandStream(consoleInput), false))
break;
}
} else {
@@ -105,28 +111,22 @@ protected boolean isInteractiveMode(String[] args) {
protected boolean executeBatch(final String commandLine) {
final File commandFile = new File(commandLine);
- Scanner scanner = null;
-
+ OCommandStream scanner;
try {
- scanner = new Scanner(commandFile);
+ scanner = new ODFACommandStream(commandFile);
} catch (FileNotFoundException e) {
- scanner = new Scanner(commandLine);
+ scanner = new ODFACommandStream(commandLine);
}
return executeCommands(scanner, true);
}
- protected boolean executeCommands(final Scanner iScanner, final boolean iExitOnException) {
+ protected boolean executeCommands(final OCommandStream commandStream, final boolean iExitOnException) {
final StringBuilder commandBuffer = new StringBuilder();
try {
- String commandLine = null;
-
- iScanner.useDelimiter(";(?=([^\"]*\"[^\"]*\")*[^\"]*$)(?=([^']*'[^']*')*[^']*$)|\n");
-
- while (iScanner.hasNext()) {
-
- commandLine = iScanner.next().trim();
+ while (commandStream.hasNext()) {
+ String commandLine = commandStream.nextCommand();
if (commandLine.isEmpty())
// EMPTY LINE
@@ -167,7 +167,7 @@ protected boolean executeCommands(final Scanner iScanner, final boolean iExitOnE
return false;
}
} finally {
- iScanner.close();
+ commandStream.close();
}
return true;
}
@@ -349,7 +349,7 @@ protected void syntaxError(String iCommand, Method m) {
/**
* Returns a map of all console method and the object they can be called on.
*
- * @return Map
+ * @return Map<Method,Object>
*/
protected Map getConsoleMethods() {
diff --git a/commons/src/main/java/com/orientechnologies/common/console/ODFACommandStream.java b/commons/src/main/java/com/orientechnologies/common/console/ODFACommandStream.java
new file mode 100755
index 00000000000..321a14e3eef
--- /dev/null
+++ b/commons/src/main/java/com/orientechnologies/common/console/ODFACommandStream.java
@@ -0,0 +1,257 @@
+package com.orientechnologies.common.console;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.CharBuffer;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Artem Orobets
+ */
+public class ODFACommandStream implements OCommandStream {
+ public static final int BUFFER_SIZE = 1024;
+
+ private Reader reader;
+ private CharBuffer buffer;
+ private final Set separators = new HashSet(Arrays.asList(';', '\n'));
+ private int position;
+ private int start;
+ private int end;
+ private StringBuilder partialResult;
+ private State state;
+
+ public ODFACommandStream(String commands) {
+ reader = new StringReader(commands);
+ init();
+ }
+
+ public ODFACommandStream(File file) throws FileNotFoundException {
+ reader = new BufferedReader(new FileReader(file));
+ init();
+ }
+
+ private void init() {
+ buffer = CharBuffer.allocate(BUFFER_SIZE);
+ buffer.flip();
+ }
+
+ @Override
+ public boolean hasNext() {
+ try {
+ fillBuffer();
+
+ return buffer.hasRemaining();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void fillBuffer() throws IOException {
+ if (!buffer.hasRemaining()) {
+ buffer.clear();
+ reader.read(buffer);
+ buffer.flip();
+ }
+ }
+
+ @Override
+ public String nextCommand() {
+ try {
+ fillBuffer();
+
+ partialResult = new StringBuilder();
+ state = State.S;
+ start = 0;
+ end = -1;
+ position = 0;
+ Symbol s = null;
+ while (state != State.E) {
+ s = nextSymbol();
+
+ final State newState = transition(state, s);
+
+ if (state == State.S && newState != State.S)
+ start = position;
+
+ if (newState == State.A)
+ end = position;
+
+ if (newState == State.F)
+ throw new IllegalStateException("Unexpected end of file");
+
+ state = newState;
+ position++;
+ }
+
+ if (s == Symbol.EOF) {
+ position--;
+ if (end == -1) {
+ start = 0;
+ end = 0;
+ }
+ }
+
+ final String result;
+ if (partialResult.length() > 0) {
+ if (end > 0) {
+ result = partialResult.append(buffer.subSequence(start, end + 1).toString()).toString();
+ } else {
+ partialResult.setLength(partialResult.length() + end + 1);
+ result = partialResult.toString();
+ }
+ } else {
+ result = buffer.subSequence(start, end + 1).toString();
+ }
+
+ buffer.position(buffer.position() + position);
+ return result;
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Symbol nextSymbol() throws IOException {
+ Symbol s;
+ if (buffer.position() + position < buffer.limit()) {
+ s = symbol(buffer.charAt(position));
+ } else {
+ buffer.compact();
+ int read = reader.read(buffer);
+ buffer.flip();
+
+ if (read == 0) {
+ // There is something in source, but buffer is full
+
+ if (state != State.S)
+ partialResult.append(buffer.subSequence(start, position).toString());
+ start = 0;
+ end = end - position;
+ buffer.clear();
+ read = reader.read(buffer);
+ buffer.flip();
+ position = 0;
+ }
+
+ if (read == -1) {
+ s = Symbol.EOF;
+ } else {
+ s = symbol(buffer.charAt(position));
+ }
+ }
+ return s;
+ }
+
+ private State transition(State s, Symbol c) {
+ switch (s) {
+ case S:
+ switch (c) {
+ case LATTER:
+ return State.A;
+ case WS:
+ return State.S;
+ case AP:
+ return State.B;
+ case QT:
+ return State.C;
+ case SEP:
+ return State.S;
+ case EOF:
+ return State.E;
+ }
+ break;
+ case A:
+ case D:
+ switch (c) {
+ case LATTER:
+ return State.A;
+ case WS:
+ return State.D;
+ case AP:
+ return State.B;
+ case QT:
+ return State.C;
+ case SEP:
+ return State.E;
+ case EOF:
+ return State.E;
+ }
+ break;
+ case B:
+ switch (c) {
+ case LATTER:
+ return State.B;
+ case WS:
+ return State.B;
+ case AP:
+ return State.A;
+ case QT:
+ return State.B;
+ case SEP:
+ return State.B;
+ case EOF:
+ return State.F;
+ }
+ break;
+ case C:
+ switch (c) {
+ case LATTER:
+ return State.C;
+ case WS:
+ return State.C;
+ case AP:
+ return State.C;
+ case QT:
+ return State.A;
+ case SEP:
+ return State.C;
+ case EOF:
+ return State.F;
+ }
+ break;
+ case E:
+ return State.E;
+ case F:
+ return State.F;
+ }
+
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public void close() {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Symbol symbol(Character c) {
+ if (c.equals('\''))
+ return Symbol.AP;
+ if (c.equals('"'))
+ return Symbol.QT;
+ if (separators.contains(c))
+ return Symbol.SEP;
+ if (Character.isWhitespace(c))
+ return Symbol.WS;
+
+ return Symbol.LATTER;
+ }
+
+ private enum State {
+ S, A, B, C, D, E, F
+ }
+
+ private enum Symbol {
+ LATTER, WS, QT, AP, SEP, EOF
+ }
+}
diff --git a/commons/src/main/java/com/orientechnologies/common/console/OScannerCommandStream.java b/commons/src/main/java/com/orientechnologies/common/console/OScannerCommandStream.java
new file mode 100755
index 00000000000..c729f5ec9c5
--- /dev/null
+++ b/commons/src/main/java/com/orientechnologies/common/console/OScannerCommandStream.java
@@ -0,0 +1,41 @@
+package com.orientechnologies.common.console;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Scanner;
+
+/**
+ * @author Artem Orobets
+ */
+public class OScannerCommandStream implements OCommandStream {
+ private Scanner scanner;
+
+ public OScannerCommandStream(String commands) {
+ scanner = new Scanner(commands);
+ init();
+ }
+
+ public OScannerCommandStream(File file) throws FileNotFoundException {
+ scanner = new Scanner(file);
+ init();
+ }
+
+ private void init() {
+ scanner.useDelimiter(";(?=([^\"]*\"[^\"]*\")*[^\"]*$)(?=([^']*'[^']*')*[^']*$)|\n");
+ }
+
+ @Override
+ public boolean hasNext() {
+ return scanner.hasNext();
+ }
+
+ @Override
+ public String nextCommand() {
+ return scanner.next().trim();
+ }
+
+ @Override
+ public void close() {
+ scanner.close();
+ }
+}
diff --git a/commons/src/main/java/com/orientechnologies/common/profiler/OProfiler.java b/commons/src/main/java/com/orientechnologies/common/profiler/OProfiler.java
index dde561fd1ea..394c164dbbe 100644
--- a/commons/src/main/java/com/orientechnologies/common/profiler/OProfiler.java
+++ b/commons/src/main/java/com/orientechnologies/common/profiler/OProfiler.java
@@ -36,7 +36,7 @@ public class OProfiler extends OAbstractProfiler {
public OProfiler() {
}
- public OProfiler(final OProfiler profiler) {
+ public OProfiler(final OAbstractProfiler profiler) {
super(profiler);
}
diff --git a/commons/src/test/java/com/orientechnologies/common/console/ODFACommandStreamTest.java b/commons/src/test/java/com/orientechnologies/common/console/ODFACommandStreamTest.java
new file mode 100755
index 00000000000..739d330dee5
--- /dev/null
+++ b/commons/src/test/java/com/orientechnologies/common/console/ODFACommandStreamTest.java
@@ -0,0 +1,45 @@
+package com.orientechnologies.common.console;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Artem Orobets
+ */
+public class ODFACommandStreamTest {
+ @Test
+ public void testNextCommand() throws Exception {
+ test("one;two", "one", "two");
+ }
+
+ @Test
+ public void testNextCommandQuotes() throws Exception {
+ test("Select 'one;'; Select \"t;w;o\"", "Select 'one;'", "Select \"t;w;o\"");
+ }
+
+ @Test
+ public void testNextCommandSeparatorAtTheEnd() throws Exception {
+ test("one;two;", "one", "two");
+ }
+
+ @Test
+ public void testNextCommandWhitespaces() throws Exception {
+ test("\tone ; two ", "one", "two");
+ }
+
+ private void test(String source, String... expectedResults) {
+ final ODFACommandStream stream = new ODFACommandStream(source);
+
+ for (String expectedResult : expectedResults) {
+ Assert.assertTrue(stream.hasNext());
+
+ String result = stream.nextCommand();
+ Assert.assertEquals(result, expectedResult);
+ }
+
+ Assert.assertFalse(stream.hasNext());
+ }
+}
diff --git a/core/pom.xml b/core/pom.xml
index 55b276d1c24..88eaad9f0d8 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -17,7 +17,7 @@
com.orientechnologies
orientdb-parent
- 1.6.1
+ 1.6.2
../
@@ -34,6 +34,7 @@
org.iq80.snappy;resolution:=optional,
javax.imageio.spi,sun.misc;resolution:=optional,
com.orientechnologies.nio;resolution:=optional,
+ com.orientechnologies.orient.client.remote;resolution:=optional,
*
com.orientechnologies.orient.core.*
diff --git a/core/src/main/java/com/orientechnologies/orient/core/OConstants.java b/core/src/main/java/com/orientechnologies/orient/core/OConstants.java
index 95e6fc21768..756c09cf2bd 100644
--- a/core/src/main/java/com/orientechnologies/orient/core/OConstants.java
+++ b/core/src/main/java/com/orientechnologies/orient/core/OConstants.java
@@ -16,7 +16,7 @@
package com.orientechnologies.orient.core;
public class OConstants {
- public static final String ORIENT_VERSION = "1.6.1";
+ public static final String ORIENT_VERSION = "1.6.2";
public static final String ORIENT_URL = "www.orientechnologies.com";
public static String getVersion() {
diff --git a/core/src/main/java/com/orientechnologies/orient/core/collate/OCaseInsensitiveCollate.java b/core/src/main/java/com/orientechnologies/orient/core/collate/OCaseInsensitiveCollate.java
new file mode 100644
index 00000000000..974e482c43f
--- /dev/null
+++ b/core/src/main/java/com/orientechnologies/orient/core/collate/OCaseInsensitiveCollate.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2010-2013 Luca Garulli (l.garulli--at--orientechnologies.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.
+ */
+package com.orientechnologies.orient.core.collate;
+
+import com.orientechnologies.common.comparator.ODefaultComparator;
+
+/**
+ * Case insensitive collate.
+ *
+ * @author Luca Garulli (l.garulli--at--orientechnologies.com)
+ *
+ */
+public class OCaseInsensitiveCollate extends ODefaultComparator implements OCollate {
+ public String getName() {
+ return "ci";
+ }
+
+ public Object transform(final Object obj) {
+ if (obj instanceof String)
+ return ((String) obj).toLowerCase();
+ return obj;
+ }
+}
diff --git a/core/src/main/java/com/orientechnologies/orient/core/collate/OCollate.java b/core/src/main/java/com/orientechnologies/orient/core/collate/OCollate.java
new file mode 100644
index 00000000000..31682af8503
--- /dev/null
+++ b/core/src/main/java/com/orientechnologies/orient/core/collate/OCollate.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010-2013 Luca Garulli (l.garulli--at--orientechnologies.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.
+ */
+package com.orientechnologies.orient.core.collate;
+
+import java.util.Comparator;
+
+/**
+ * Specify the Collating strategy when comparison in SQL statement is required.
+ *
+ * @author Luca Garulli (l.garulli--at--orientechnologies.com)
+ *
+ */
+public interface OCollate extends Comparator