Search in sources :

Example 6 with CacheException

use of org.apache.geode.cache.CacheException in project geode by apache.

the class DistributedTXRegionStub method putEntry.

public boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) {
    boolean retVal = false;
    final LocalRegion r = event.getLocalRegion();
    try {
        RemotePutResponse response = RemotePutMessage.txSend(state.getTarget(), r, event, lastModified, ifNew, ifOld, expectedOldValue, requireOldValue);
        PutResult result = response.waitForResult();
        event.setOldValue(result.oldValue, true);
        retVal = result.returnValue;
    } catch (TransactionDataNotColocatedException enfe) {
        throw enfe;
    } catch (CacheException ce) {
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_DESTROY_OF_ENTRY_ON_0_FAILED.toLocalizedString(state.getTarget()), ce);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
    return retVal;
}
Also used : PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) CacheException(org.apache.geode.cache.CacheException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemotePutResponse(org.apache.geode.internal.cache.RemotePutMessage.RemotePutResponse) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PutResult(org.apache.geode.internal.cache.RemotePutMessage.PutResult) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 7 with CacheException

use of org.apache.geode.cache.CacheException in project geode by apache.

the class CompiledInDUnitTest method whenMultipleTypeBindParameterIsUsedWithInQueryAndMapIndexIsPresentInPartitionRegionReturnCorrectResults.

@Test
public void whenMultipleTypeBindParameterIsUsedWithInQueryAndMapIndexIsPresentInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1,$2,$3)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createIndex("myIndex", "ts.getMapField[*]", regName + " ts");
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { 2, DayEnum.MONDAY, "Tuesday" };
    vm1.invoke(executeQueryOnPartitionRegion(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 8 with CacheException

use of org.apache.geode.cache.CacheException in project geode by apache.

the class CompiledInDUnitTest method whenASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults.

@Test
public void whenASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY };
    vm1.invoke(executeQueryOnPartitionRegion(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 9 with CacheException

use of org.apache.geode.cache.CacheException in project geode by apache.

the class CompiledInDUnitTest method whenUsingAccessorASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults.

@Test
public void whenUsingAccessorASingleEnumBindParameterIsUsedWithInQueryInPartitionRegionReturnCorrectResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = numberOfEntries / 2;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createPartitionRegion(false);
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY };
    vm1.invoke(executeQueryWithAccessor(numExpectedResults, queryString, bindArguments));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 10 with CacheException

use of org.apache.geode.cache.CacheException in project geode by apache.

the class CompiledInDUnitTest method whenANDConditionWithInSetFiltersOutAllFieldsReturnNoResults.

@Test
public void whenANDConditionWithInSetFiltersOutAllFieldsReturnNoResults() throws CacheException {
    final int numberOfEntries = 10;
    final int numExpectedResults = 0;
    final String queryString = "select * from " + regName + " where getMapField['1'] in SET ($1, $2) AND getMapField['1'] in SET($3)";
    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {

        public void run2() throws CacheException {
            configAndStartBridgeServer();
            createReplicateRegion();
            createIndex("myIndex", "ts.getMapField[*]", regName + " ts");
            createEntries(numberOfEntries, regionName);
        }
    });
    Object[] bindArguments = new Object[] { DayEnum.MONDAY, DayEnum.TUESDAY, DayEnum.WEDNESDAY };
    vm1.invoke(executeQueryWithIndexOnReplicateRegion(numExpectedResults, queryString, bindArguments, "myIndex", "ts.getMapField[*]", regName + " ts"));
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

CacheException (org.apache.geode.cache.CacheException)638 Test (org.junit.Test)445 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)407 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)376 VM (org.apache.geode.test.dunit.VM)375 Region (org.apache.geode.cache.Region)351 Host (org.apache.geode.test.dunit.Host)330 AttributesFactory (org.apache.geode.cache.AttributesFactory)204 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)201 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)191 IOException (java.io.IOException)124 LocalRegion (org.apache.geode.internal.cache.LocalRegion)118 QueryService (org.apache.geode.cache.query.QueryService)107 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)85 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)85 SelectResults (org.apache.geode.cache.query.SelectResults)80 IgnoredException (org.apache.geode.test.dunit.IgnoredException)72 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)64 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)61 Cache (org.apache.geode.cache.Cache)59