Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java24
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java29
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOIDList.java)10
10 files changed, 74 insertions, 57 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
index 15cb327033..a71f333740 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
@@ -52,6 +52,7 @@ public class PollIterator<E> implements Iterator<E>
public void remove()
{
+ throw new UnsupportedOperationException();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index 8b85da7987..d3ee7bacc2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -131,9 +131,9 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
{
CDORevision revision = getStore().getRevision(id);
- CDOPathFeature pathFeature = getStore().getRepository().getPackageManager().getCDOResourcePackage().getCDOResourceClass()
- .getCDOPathFeature();
-
+ CDOPathFeature pathFeature = getStore().getRepository().getPackageManager().getCDOResourcePackage()
+ .getCDOResourceClass().getCDOPathFeature();
+
String p = (String)revision.getData().get(pathFeature, 0);
return p;
@@ -199,16 +199,16 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
if (queryParameter.getQueryLanguage().equals("TEST"))
{
// queryParameter.getQueryString().equals("SLOW");
- MEMStoreQueryIterator queryExecution = new MEMStoreQueryIterator(this.getStore());
-
+ MEMStoreQueryIterator queryExecution = new MEMStoreQueryIterator(this.getStore());
+
Object context = queryParameter.getParameters().get("context");
-
+
if (context != null)
{
if (context instanceof CDOClass)
{
final CDOClass cdoClass = (CDOClass)context;
-
+
queryExecution.addFilter(new Object()
{
@@ -216,16 +216,15 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
public boolean equals(Object obj)
{
CDORevision revision = (CDORevision)obj;
- return revision.getCDOClass().equals( cdoClass );
+ return revision.getCDOClass().equals(cdoClass);
}
-
- }
- );
+
+ });
}
}
-
+
queryExecution.activate();
-
+
return queryExecution;
}
throw new RuntimeException("Unsupported language " + queryParameter.getQueryLanguage());
@@ -237,6 +236,6 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
*/
public void refreshRevisions()
{
-
- }
+
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
index 29c5ed0f9a..657e2ed2c2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
@@ -69,16 +69,6 @@ public class MEMStoreQueryIterator implements CloseableIterator<Object>
public boolean hasNext()
{
- try
- {
- // @TODO only for test purpose need to be removed.
- Thread.sleep(500);
- }
- catch (InterruptedException ex)
- {
- Thread.currentThread().interrupt();
- }
-
return nextObject != null;
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
index d7a03bab51..b5ede84371 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
@@ -55,7 +55,7 @@ public class QueryIndication extends CDOReadIndication
IView view = getSession().getView(viewID);
QueryManager queryManager = getRepository().getQueryManager();
-
+
queryResult = queryManager.execute(view, cdoQuery);
}
@@ -72,7 +72,6 @@ public class QueryIndication extends CDOReadIndication
// Return queryID immediately.
out.writeLong(queryResult.getQueryID());
out.flush();
-
while (queryResult.hasNext())
{
Object object = queryResult.next();
@@ -86,6 +85,7 @@ public class QueryIndication extends CDOReadIndication
{
// Flush only if empty
out.flush();
+
}
}
if (TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java
index e7ce18bf94..f6c1a0fa12 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/QueryTest.java
@@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
-import org.eclipse.emf.internal.cdo.query.CDOQueryImpl;
import org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl;
import org.eclipse.net4j.util.collection.CloseableIterator;
@@ -59,7 +58,7 @@ public class QueryTest extends AbstractCDOTest
transaction.commit();
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
List<Object> queryResult = cdoQuery.getResultList(Object.class);
assertEquals(3, queryResult.size());
for (Object object : queryResult)
@@ -95,7 +94,7 @@ public class QueryTest extends AbstractCDOTest
System.out.println(category1.eClass().getEPackage().getNsURI());
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
cdoQuery.setParameter("context", Model1Package.eINSTANCE.getCategory());
@@ -110,10 +109,10 @@ public class QueryTest extends AbstractCDOTest
public void testQueryCancel_successful() throws Exception
{
- CDOTransaction transaction = initialize(100);
+ CDOTransaction transaction = initialize(1000);
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
- CloseableIterator<Object> queryResult = ((CDOQueryImpl)cdoQuery).getResultIterator(Object.class);
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
+ CloseableIterator<Object> queryResult = cdoQuery.getResultIterator(Object.class);
queryResult.close();
@@ -128,7 +127,7 @@ public class QueryTest extends AbstractCDOTest
{
CDOTransaction transaction = initialize(100);
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
CloseableIterator<Object> queryResult = cdoQuery.getResultIterator(Object.class);
Thread.sleep(300);
@@ -143,7 +142,7 @@ public class QueryTest extends AbstractCDOTest
{
CDOTransaction transaction = initialize(100);
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
CloseableIterator<Object> queryResult = cdoQuery.getResultIterator(Object.class);
Thread.sleep(300);
@@ -159,17 +158,18 @@ public class QueryTest extends AbstractCDOTest
{
CDOTransaction transaction = initialize(2);
- CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "TEST");
+ CDOQuery cdoQuery = transaction.createQuery(LANGUAGE_TEST, "QUERYSTRING");
CDOQueryResult<Object> queryResult = cdoQuery.getResultIterator(Object.class);
while (!queryResult.isDone())
{
Thread.sleep(10);
}
+
try
{
- queryResult.close();
- assertEquals(false, true);
+ queryResult.cancel();
+ fail("Should throw an exception");
}
catch (Exception exception)
{
@@ -184,7 +184,7 @@ public class QueryTest extends AbstractCDOTest
{
CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
-
+ transaction.setUniqueResourceContents(false);
CDOResource resource1 = transaction.createResource("/test1");
for (int i = 0; i < number; i++)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java
index 27adeaa5e6..613c6fbcb3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java
@@ -18,5 +18,10 @@ import org.eclipse.emf.cdo.common.query.ResultReaderQueue;
*/
public interface CDOQueryResult<T> extends ResultReaderQueue<T>
{
-
+ /**
+ * It will throw an exception if not running.
+ * <p>
+ * Use close to terminate the query without throwing an exception
+ */
+ void cancel();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
index 70a895150b..655e5330ea 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
@@ -66,23 +66,30 @@ public class QueryRequest extends CDOClientRequest<Object>
cdoQuery.write(out);
}
-
+
@Override
protected List<Object> confirming(ExtendedDataInputStream in) throws IOException
{
List<Object> returnList = new ArrayList<Object>();
-
+
queryResult.setQueryID(in.readLong());
-
+
LifecycleUtil.activate(queryResult);
-
+
ResultWriterQueue<Object> resulQueue = queryResult.getResultQueue();
-
+
try
{
int numberOfObjectReceived = 0;
-
+
+ /**
+ * state == 0 : Result
+ * <p>
+ * state == 1 : No more result
+ * <p>
+ * state == 2 : Exception
+ */
while (true)
{
byte state = in.readByte();
@@ -93,7 +100,7 @@ public class QueryRequest extends CDOClientRequest<Object>
Object element = CDOInstanceUtil.readInstance(in, getSession());
resulQueue.add(element);
-
+
numberOfObjectReceived++;
}
else if (state == 1)
@@ -107,8 +114,10 @@ public class QueryRequest extends CDOClientRequest<Object>
String exceptionString = in.readString();
throw new RuntimeException(exceptionString);
}
+ else
+ throw new IllegalStateException();
}
-
+
if (PROTOCOL.isEnabled())
{
PROTOCOL.trace("Query executed [" + numberOfObjectReceived + " elements received]");
@@ -117,7 +126,7 @@ public class QueryRequest extends CDOClientRequest<Object>
catch (RuntimeException ex)
{
resulQueue.setException(ex);
-
+
}
catch (Throwable throwable)
{
@@ -127,7 +136,7 @@ public class QueryRequest extends CDOClientRequest<Object>
{
resulQueue.release();
}
-
+
return returnList;
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
index f94eacf730..3d5126173c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
@@ -52,9 +52,9 @@ public class CDOQueryImpl implements CDOQuery
{
CDOQueryParameterImpl queryParameter = new CDOQueryParameterImpl(this.queryParameter.getQueryLanguage(),
this.queryParameter.getQueryString());
-
+
queryParameter.setMaxResult(maxResult);
-
+
for (Entry<String, Object> entry : parameters.entrySet())
{
Object value = entry.getValue();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
index 4117ab8bb2..d798fcff83 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
@@ -85,6 +85,18 @@ public class CDOQueryResultIteratorImpl<T> extends CDOAbstractQueryResultImpl<T>
public void close()
{
+ try
+ {
+ cancel();
+ }
+ catch (RuntimeException ex)
+ {
+ // Hide exception
+ }
+ }
+
+ public void cancel()
+ {
cancelled = true;
try
{
@@ -94,6 +106,7 @@ public class CDOQueryResultIteratorImpl<T> extends CDOAbstractQueryResultImpl<T>
{
throw new RuntimeException(ex);
}
+
}
public boolean isCancelled()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOIDList.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java
index fd1f96b726..7a9e9d76b9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOIDList.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java
@@ -24,13 +24,13 @@ import java.util.ListIterator;
/**
* @author Simon McDuff
*/
-public class ECDOIDList<T> implements EList<T>
+public class ECDOList<T> implements EList<T>
{
private List<Object> listOfIDs;
private CDOView cdoView;
- public ECDOIDList(CDOView view, List<Object> list)
+ public ECDOList(CDOView view, List<Object> list)
{
this.listOfIDs = list;
this.cdoView = view;
@@ -77,7 +77,7 @@ public class ECDOIDList<T> implements EList<T>
public void move(int newPosition, T object)
{
-
+ throw new UnsupportedOperationException();
}
public T move(int newPosition, int oldPosition)
@@ -127,7 +127,7 @@ public class ECDOIDList<T> implements EList<T>
public ListIterator<T> listIterator(int arg0)
{
- return null;
+ throw new UnsupportedOperationException();
}
public boolean remove(Object arg0)
@@ -169,7 +169,7 @@ public class ECDOIDList<T> implements EList<T>
{
throw new UnsupportedOperationException();
}
-
+
@SuppressWarnings("hiding")
public <T> T[] toArray(T[] arg0)
{

Back to the top