use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ClientInterestNotifyDUnitTest method registerInterest.
/**
* register interest with the server on ALL_KEYS
*
*/
public static void registerInterest() {
try {
Cache cacheClient = GemFireCacheImpl.getInstance();
Region region1 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME1);
Region region2 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME2);
// We intentionally do not register interest in region 3 to check no events recvd.
Region region3 = cacheClient.getRegion(Region.SEPARATOR + REGION_NAME3);
assertTrue(region1 != null);
assertTrue(region2 != null);
assertTrue(region3 != null);
region1.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES, false, true);
region2.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES, false, false);
// We intentionally do not register interest in region 3 to check no events recvd.
// region3.registerInterestBlah();
} catch (CacheWriterException e) {
fail("test failed due to " + e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ClientServerMiscDUnitTest method registerInterestForInvalidatesInBothTheRegions.
public static void registerInterestForInvalidatesInBothTheRegions() {
try {
Cache cache = new ClientServerMiscDUnitTest().getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
assertNotNull(r2);
r1.registerInterest("ALL_KEYS", false, false);
r2.registerInterest("ALL_KEYS", false, false);
} catch (CacheWriterException e) {
e.printStackTrace();
Assert.fail("Test failed due to CacheWriterException during registerInterestnBothRegions", e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class ConflationDUnitTest method unregisterInterest.
/**
* register interest with the server on ALL_KEYS
*
*/
public static void unregisterInterest() {
try {
Region region1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
Region region2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2);
region1.unregisterInterest("ALL_KEYS");
region2.unregisterInterest("ALL_KEYS");
} catch (CacheWriterException e) {
fail("test failed due to " + e);
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class QueryResultData method executeQueryTestCases.
private void executeQueryTestCases() {
HttpHeaders headers = setAcceptAndContentTypeHeaders();
HttpEntity<Object> entity;
int totalRequests = TEST_DATA.length;
String expectedEx = null;
for (int index = 0; index < totalRequests; index++) {
try {
expectedEx = addExpectedException(index);
final String restRequestUrl = createRestURL(this.baseURL, TEST_DATA[index][URL_INDEX]);
entity = new HttpEntity<>(TEST_DATA[index][REQUEST_BODY_INDEX], headers);
ResponseEntity<String> result = RestTestUtils.getRestTemplate().exchange(restRequestUrl, (HttpMethod) TEST_DATA[index][METHOD_INDEX], entity, String.class);
validateGetAllResult(index, result);
validateQueryResult(index, result);
assertEquals(result.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
assertEquals(result.hasBody(), ((Boolean) TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
verifyRegionSize(index, result);
// TODO:
// verify location header
} catch (HttpClientErrorException e) {
if (VALID_409_URL_INDEXS.contains(index)) {
// create-409, conflict testcase. [create on already existing key]
assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean) TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
} else if (VALID_400_URL_INDEXS.contains(index)) {
// 400, Bad Request testcases. [create with malformed Json]
assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean) TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
} else if (VALID_404_URL_INDEXS.contains(index)) {
// create-404, Not Found testcase. [create on not-existing region]
assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean) TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
} else if (VALID_405_URL_INDEXS.contains(index)) {
// create-404, Not Found testcase. [create on not-existing region]
assertEquals(e.getStatusCode(), TEST_DATA[index][STATUS_CODE_INDEX]);
assertEquals(StringUtils.hasText(e.getResponseBodyAsString()), ((Boolean) TEST_DATA[index][RESPONSE_HAS_BODY_INDEX]).booleanValue());
} else {
fail("Index:" + index + " " + TEST_DATA[index][METHOD_INDEX] + " " + TEST_DATA[index][URL_INDEX] + " should not have thrown exception ");
}
} catch (HttpServerErrorException se) {
// index=4, create- 500, INTERNAL_SERVER_ERROR testcase. [create on Region with
// DataPolicy=Empty set]
// index=7, create- 500, INTERNAL_SERVER_ERROR testcase. [Get, attached cache loader throws
// Timeout exception]
// index=11, put- 500, [While doing R.put, CacheWriter.beforeCreate() has thrown
// CacheWriterException]
// .... and more test cases
assertEquals(TEST_DATA[index][STATUS_CODE_INDEX], se.getStatusCode());
assertEquals(TEST_DATA[index][RESPONSE_HAS_BODY_INDEX], StringUtils.hasText(se.getResponseBodyAsString()));
} catch (Exception e) {
caught("caught Exception in executeQueryTestCases " + "Index:" + index + " " + TEST_DATA[index][METHOD_INDEX] + " " + TEST_DATA[index][URL_INDEX] + " :: Unexpected ERROR...!!", e);
} finally {
c.getLogger().info("<ExpectedException action=remove>" + expectedEx + "</ExpectedException>");
}
}
}
use of org.apache.geode.cache.CacheWriterException in project geode by apache.
the class HARegion method findObjectInSystem.
/**
* @return the deserialized value
* @see LocalRegion#findObjectInSystem(KeyInfo, boolean, TXStateInterface, boolean, Object,
* boolean, boolean, ClientProxyMembershipID, EntryEventImpl, boolean)
*
*/
@Override
protected Object findObjectInSystem(KeyInfo keyInfo, boolean isCreate, TXStateInterface txState, boolean generateCallbacks, Object localValue, boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones) throws CacheLoaderException, TimeoutException {
Object value = null;
final Object key = keyInfo.getKey();
final Object aCallbackArgument = keyInfo.getCallbackArg();
// copy into local var to prevent race condition
RegionEntry re = null;
Assert.assertTrue(!hasServerProxy());
CacheLoader loader = basicGetLoader();
if (loader != null) {
final LoaderHelper loaderHelper = loaderHelperFactory.createLoaderHelper(key, aCallbackArgument, false, /* netSearchAllowed */
true, /* netloadallowed */
null);
try {
value = loader.load(loaderHelper);
} finally {
}
if (value != null) {
try {
validateKey(key);
Operation op;
if (isCreate) {
op = Operation.LOCAL_LOAD_CREATE;
} else {
op = Operation.LOCAL_LOAD_UPDATE;
}
@Released EntryEventImpl event = EntryEventImpl.create(this, op, key, value, aCallbackArgument, false, getMyId(), generateCallbacks);
try {
re = basicPutEntry(event, 0L);
} finally {
event.release();
}
if (txState == null) {
}
} catch (CacheWriterException cwe) {
// @todo smenon Log the exception
}
}
}
if (isCreate) {
recordMiss(re, key);
}
return value;
}
Aggregations