org.apache.geode.cache.execute.Execution.withFilter()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.geode.cache.execute.Execution.withFilter()方法的一些代码示例,展示了Execution.withFilter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Execution.withFilter()方法的具体详情如下:
包路径:org.apache.geode.cache.execute.Execution
类名称:Execution
方法名:withFilter

Execution.withFilter介绍

[英]Specifies a data filter of routing objects for selecting the GemFire members to execute the function on.

Applicable only for regions with DataPolicy#PARTITION DataPolicy. If the filter is null, it will execute on all data of the region.
[中]指定路由对象的数据筛选器,用于选择要在其上执行函数的GemFire成员。
仅适用于具有DataPolicy#分区DataPolicy的区域。如果筛选器为空,则它将对该区域的所有数据执行。

代码示例

代码示例来源:origin: apache/geode

@Override
public int size() {
 // Add a single dummy key to force the function to go to one server
 Set<String> filters = new HashSet<String>();
 filters.add("test-key");
 // Execute the function on the session region
 Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(filters);
 ResultCollector collector = execution.execute(RegionSizeFunction.ID);
 List<Integer> result = (List<Integer>) collector.getResult();
 // Return the first (and only) element
 return result.get(0);
}

代码示例来源:origin: apache/geode

@Override
 public Map answer(InvocationOnMock invocation) throws Throwable {
  ArgumentCaptor<Set> captor = ArgumentCaptor.forClass(Set.class);
  verify(execution, atLeast(1)).withFilter(captor.capture());
  Collection<String> keys = captor.getValue();
  Map<String, String> results = new HashMap<String, String>();
  for (String key : keys) {
   results.put(key, key.replace("key_", "value_"));
  }
  return results;
 }
});

代码示例来源:origin: apache/geode

@Override
public List<Object> executeFunctionOnRegion(String functionID, String regionName,
  Object arguments, Set<?> keyFilter) {
 Function function = authorizeAndGetFunction(regionName, functionID, arguments);
 Region region = getRegion(regionName);
 Execution execution = FunctionService.onRegion(region);
 if (keyFilter != null) {
  execution = execution.withFilter(keyFilter);
 }
 return executeFunction(execution, functionID, function, arguments);
}

代码示例来源:origin: apache/geode

protected Map<K, V> getValues(final Set<K> keys) {
 ResultCollector resultCollector = onRegion().withFilter(keys)
   .withCollector(new MapResultCollector()).execute(LuceneGetPageFunction.ID);
 return (Map<K, V>) resultCollector.getResult();
}

代码示例来源:origin: apache/geode

@Test
@SuppressWarnings("unchecked")
public void executeShouldProperlyConfigureExecutionContext() {
 Set<String> filter = new HashSet<>();
 filter.add("key1");
 filter.add("key2");
 arguments = new Object[] {"TestFunction", "key1,key2", "TestResultCollector", "arg1,arg2",
   "/TestRegion", new Properties()};
 when(context.getArguments()).thenReturn(arguments);
 function.execute(context);
 verify(execution, times(1)).withFilter(filter);
 verify(execution, times(1)).withCollector(resultCollector);
 verify(execution, times(1)).setArguments(new String[] {"arg1", "arg2"});
 verify(resultSender, times(1)).lastResult(resultCaptor.capture());
 CliFunctionResult resultFullArguments = resultCaptor.getValue();
 assertThat(resultFullArguments.isSuccessful()).isTrue();
 reset(resultSender);
 reset(execution);
 arguments = new Object[] {"TestFunction", "", "", "", "", new Properties()};
 when(context.getArguments()).thenReturn(arguments);
 function.execute(context);
 verify(execution, never()).withFilter(any());
 verify(execution, never()).setArguments(any());
 verify(execution, never()).withCollector(any());
 verify(resultSender, times(1)).lastResult(resultCaptor.capture());
 CliFunctionResult resultNoArguments = resultCaptor.getValue();
 assertThat(resultNoArguments.isSuccessful()).isTrue();
}

代码示例来源:origin: apache/geode

@Before
public void setUp() {
 hits = new ArrayList<EntryScore<String>>();
 for (int i = 0; i < 23; i++) {
  hits.add(new EntryScore("key_" + i, i));
  expected.add(new LuceneResultStructImpl<String, String>("key_" + i, "value_" + i, i));
 }
 userRegion = mock(Region.class);
 final ResultCollector collector = mock(ResultCollector.class);
 execution = mock(Execution.class);
 when(execution.withFilter(any())).thenReturn(execution);
 when(execution.withCollector(any())).thenReturn(execution);
 when(execution.execute(anyString())).thenReturn(collector);
 when(collector.getResult()).then(new Answer() {
  @Override
  public Map answer(InvocationOnMock invocation) throws Throwable {
   ArgumentCaptor<Set> captor = ArgumentCaptor.forClass(Set.class);
   verify(execution, atLeast(1)).withFilter(captor.capture());
   Collection<String> keys = captor.getValue();
   Map<String, String> results = new HashMap<String, String>();
   for (String key : keys) {
    results.put(key, key.replace("key_", "value_"));
   }
   return results;
  }
 });
}

代码示例来源:origin: apache/geode

when(context.getResultSender()).thenReturn(resultSender);
when(execution.withFilter(any())).thenReturn(execution);
when(execution.setArguments(any())).thenReturn(execution);
when(execution.withCollector(any())).thenReturn(execution);

代码示例来源:origin: apache/geode

@Override
public void touchSessions(Set<String> sessionIds) {
 // Get the region attributes id to determine the region type. This is
 // problematic since the region attributes id doesn't really define the
 // region type. This should look at the actual session region.
 String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
 // Invoke the appropriate function depending on the type of region
 ResultCollector collector = null;
 if (regionAttributesID.startsWith("partition")) {
  // Execute the partitioned touch function on the primary server(s)
  Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
  collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID);
 } else {
  // Execute the member touch function on all the server(s)
  Execution execution = FunctionService.onMembers()
    .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds});
  collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID);
 }
 // Get the result
 try {
  collector.getResult();
 } catch (Exception e) {
  // If an exception occurs in the function, log it.
  getSessionManager().getLogger().warn("Caught unexpected exception:", e);
 }
}

代码示例来源:origin: apache/geode

Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
try {
 ResultCollector collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID);

代码示例来源:origin: apache/geode

execution = execution.withFilter(filters);

代码示例来源:origin: org.springframework.data/spring-data-gemfire

@Override
  @SuppressWarnings("unchecked")
  protected Execution getExecution() {

    Execution execution = FunctionService.onRegion(this.region);

    Set<?> keys = getKeys();

    if (!CollectionUtils.isEmpty(keys) ) {
      execution = execution.withFilter(keys);
    }

    return execution;
  }
}

代码示例来源:origin: org.springframework.data/spring-data-geode

@Override
  @SuppressWarnings("unchecked")
  protected Execution getExecution() {

    Execution execution = FunctionService.onRegion(this.region);

    Set<?> keys = getKeys();

    if (!CollectionUtils.isEmpty(keys) ) {
      execution = execution.withFilter(keys);
    }

    return execution;
  }
}

代码示例来源:origin: org.apache.geode/geode-modules

@Override
public int size() {
 // Add a single dummy key to force the function to go to one server
 Set<String> filters = new HashSet<String>();
 filters.add("test-key");
 // Execute the function on the session region
 Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(filters);
 ResultCollector collector = execution.execute(RegionSizeFunction.ID, true, true, true);
 List<Integer> result = (List<Integer>) collector.getResult();
 // Return the first (and only) element
 return result.get(0);
}

代码示例来源:origin: org.springframework.data/spring-data-gemfire

execution = getKeys() != null ? execution.withFilter(getKeys()) : execution;

代码示例来源:origin: org.springframework.data/spring-data-geode

execution = getKeys() != null ? execution.withFilter(getKeys()) : execution;

代码示例来源:origin: org.apache.geode/geode-modules

@Override
public void touchSessions(Set<String> sessionIds) {
 // Get the region attributes id to determine the region type. This is
 // problematic since the region attributes id doesn't really define the
 // region type. This should look at the actual session region.
 String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
 // Invoke the appropriate function depending on the type of region
 ResultCollector collector = null;
 if (regionAttributesID.startsWith("partition")) {
  // Execute the partitioned touch function on the primary server(s)
  Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
  collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true);
 } else {
  // Execute the member touch function on all the server(s)
  Execution execution = FunctionService.onMembers()
    .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds});
  collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
 }
 // Get the result
 try {
  collector.getResult();
 } catch (Exception e) {
  // If an exception occurs in the function, log it.
  getSessionManager().getLogger().warn("Caught unexpected exception:", e);
 }
}

代码示例来源:origin: org.apache.geode/geode-modules

Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
try {
 ResultCollector collector =

相关文章