Java Code Examples for com.gemstone.gemfire.cache.Region#getAttributesMutator()
The following examples show how to use
com.gemstone.gemfire.cache.Region#getAttributesMutator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void addGfxdCacheWriterLocally( final GemFireContainer container, String implementation, String initInfo, String serverGroups) throws StandardException { // skip writer for nodes not in the provided server groups or not in those // of the table if (skipExecutionForGroupsAndTable(serverGroups, container)) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); try { final EventCallback ecb = (EventCallback)ClassPathLoader.getLatest() .forName(implementation).newInstance(); ecb.init(initInfo); final GfxdCacheWriter writer = new GfxdCacheWriter(ecb); mutator.setCacheWriter(writer); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_WRITER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 2
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheListenerLocally(String id, final GemFireContainer container) throws StandardException { id = Misc.getFullTableName(container.getSchemaName(), id, null); final GfxdCacheListener aListener = idListenerMap.remove(id); if (aListener == null) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.removeCacheListener(aListener); aListener.close(); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LISTENER, ex, id, ex.toString()); } }
Example 3
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheWriterLocally( final GemFireContainer container) throws StandardException { @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final CacheWriter<Object, Object> prevWriter = reg.getAttributes() .getCacheWriter(); if (prevWriter == null) { return; } try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.setCacheWriter(null); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_WRITER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 4
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheLoaderLocally( final GemFireContainer container) throws StandardException { @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final CacheLoader<Object, Object> prevLoader = reg.getAttributes() .getCacheLoader(); if (prevLoader == null) { return; } try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.setCacheLoader(null); container.setLoaderInstalled(false); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LOADER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 5
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void addGfxdCacheWriterLocally( final GemFireContainer container, String implementation, String initInfo, String serverGroups) throws StandardException { // skip writer for nodes not in the provided server groups or not in those // of the table if (skipExecutionForGroupsAndTable(serverGroups, container)) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); try { final EventCallback ecb = (EventCallback)ClassPathLoader.getLatest() .forName(implementation).newInstance(); ecb.init(initInfo); final GfxdCacheWriter writer = new GfxdCacheWriter(ecb); mutator.setCacheWriter(writer); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_WRITER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 6
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheListenerLocally(String id, final GemFireContainer container) throws StandardException { id = Misc.getFullTableName(container.getSchemaName(), id, null); final GfxdCacheListener aListener = idListenerMap.remove(id); if (aListener == null) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.removeCacheListener(aListener); aListener.close(); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LISTENER, ex, id, ex.toString()); } }
Example 7
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheWriterLocally( final GemFireContainer container) throws StandardException { @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final CacheWriter<Object, Object> prevWriter = reg.getAttributes() .getCacheWriter(); if (prevWriter == null) { return; } try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.setCacheWriter(null); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_WRITER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 8
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void removeGfxdCacheLoaderLocally( final GemFireContainer container) throws StandardException { @SuppressWarnings("unchecked") final Region<Object, Object> reg = container.getRegion(); final CacheLoader<Object, Object> prevLoader = reg.getAttributes() .getCacheLoader(); if (prevLoader == null) { return; } try { final AttributesMutator<Object, Object> mutator = reg .getAttributesMutator(); mutator.setCacheLoader(null); container.setLoaderInstalled(false); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LOADER, ex, container.getQualifiedTableName(), ex.toString()); } }
Example 9
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void addGfxdCacheListenerLocally(String id, final GemFireContainer container, String implementation, String initInfo, String serverGroups) throws StandardException { // skip listener for nodes not in the provided server groups or not in those // of the table if (skipExecutionForGroupsAndTable(serverGroups, container)) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> region = container.getRegion(); final AttributesMutator<Object, Object> mutator = region .getAttributesMutator(); try { final EventCallback ecb = (EventCallback)ClassPathLoader.getLatest() .forName(implementation).newInstance(); ecb.init(initInfo); final GfxdCacheListener aListener = new GfxdCacheListener(id, ecb); id = Misc.getFullTableName(container.getSchemaName(), id, null); final GfxdCacheListener prevListener = idListenerMap.putIfAbsent(id, aListener); if (prevListener != null) { throw Util.newEmbedSQLException( SQLState.LANG_OBJECT_ALREADY_EXISTS_IN_OBJECT, new Object[] { "listener", id, "schema", container.getSchemaName() }, null); } mutator.addCacheListener(aListener); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LISTENER, ex, id, ex.toString()); } }
Example 10
Source File: MapInterfaceTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBasicMapAfterClearCalback() { Region rgn = CacheUtils.getRegion("Portfolios"); AttributesMutator atm = rgn.getAttributesMutator(); atm.setCacheListener(new CacheListenerAdapter() { @Override public void afterRegionClear(RegionEvent event) { synchronized (MapInterfaceTest.this) { event.getRegion().getCache().getLogger().info("afterRegionClear call back " + event); afterClearCallbackOccured = true; MapInterfaceTest.this.notify(); } } }); int size = rgn.size(); assertTrue( "MapInterfaceTest::basicMapClearNonTranxn: The init size of region is zero", size > 0); rgn.clear(); if (rgn.size() != 0) { fail("The region size is non zero even after issuing clear"); } if (rgn.size() != 0) { fail("The region size is non zero even after issuing clear"); } try { synchronized (this) { if (!this.afterClearCallbackOccured) { this.wait(10000); } } } catch (InterruptedException ie) { fail(ie.toString()); } if (!this.afterClearCallbackOccured) { fail("afterClear Callback not issued"); } }
Example 11
Source File: CallbackProcedures.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void addGfxdCacheListenerLocally(String id, final GemFireContainer container, String implementation, String initInfo, String serverGroups) throws StandardException { // skip listener for nodes not in the provided server groups or not in those // of the table if (skipExecutionForGroupsAndTable(serverGroups, container)) { return; } @SuppressWarnings("unchecked") final Region<Object, Object> region = container.getRegion(); final AttributesMutator<Object, Object> mutator = region .getAttributesMutator(); try { final EventCallback ecb = (EventCallback)ClassPathLoader.getLatest() .forName(implementation).newInstance(); ecb.init(initInfo); final GfxdCacheListener aListener = new GfxdCacheListener(id, ecb); id = Misc.getFullTableName(container.getSchemaName(), id, null); final GfxdCacheListener prevListener = idListenerMap.putIfAbsent(id, aListener); if (prevListener != null) { throw Util.newEmbedSQLException( SQLState.LANG_OBJECT_ALREADY_EXISTS_IN_OBJECT, new Object[] { "listener", id, "schema", container.getSchemaName() }, null); } mutator.addCacheListener(aListener); } catch (Exception ex) { throw StandardException.newException( SQLState.UNEXPECTED_EXCEPTION_FOR_LISTENER, ex, id, ex.toString()); } }
Example 12
Source File: MapInterfaceTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void testBasicMapAfterClearCalback() { Region rgn = CacheUtils.getRegion("Portfolios"); AttributesMutator atm = rgn.getAttributesMutator(); atm.setCacheListener(new CacheListenerAdapter() { @Override public void afterRegionClear(RegionEvent event) { synchronized (MapInterfaceTest.this) { event.getRegion().getCache().getLogger().info("afterRegionClear call back " + event); afterClearCallbackOccured = true; MapInterfaceTest.this.notify(); } } }); int size = rgn.size(); assertTrue( "MapInterfaceTest::basicMapClearNonTranxn: The init size of region is zero", size > 0); rgn.clear(); if (rgn.size() != 0) { fail("The region size is non zero even after issuing clear"); } if (rgn.size() != 0) { fail("The region size is non zero even after issuing clear"); } try { synchronized (this) { if (!this.afterClearCallbackOccured) { this.wait(10000); } } } catch (InterruptedException ie) { fail(ie.toString()); } if (!this.afterClearCallbackOccured) { fail("afterClear Callback not issued"); } }
Example 13
Source File: WANTestBase.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
private void addCacheListenerOnRegion(String regionName){ Region region = cache.getRegion(regionName); AttributesMutator mutator = region.getAttributesMutator(); listener1 = new QueueListener(); mutator.addCacheListener(listener1); }
Example 14
Source File: WANTestBase.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
private void addCacheListenerOnRegion(String regionName){ Region region = cache.getRegion(regionName); AttributesMutator mutator = region.getAttributesMutator(); listener1 = new QueueListener(); mutator.addCacheListener(listener1); }