use of org.apache.geode.LogWriter in project geode by apache.
the class TestFunction method execute5.
public void execute5(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
if (this.props.get("TERMINATE") != null && this.props.get("TERMINATE").equals("YES")) {
logger.info("Function Terminated");
} else {
try {
synchronized (this) {
logger.info("Function Running");
this.wait(20000);
}
} catch (InterruptedException e) {
}
}
context.getResultSender().lastResult(Boolean.TRUE);
}
use of org.apache.geode.LogWriter in project geode by apache.
the class CustomConfigWithCacheIntegrationTest method cacheLogWriterMessageShouldMatchCustomConfig.
@Test
public void cacheLogWriterMessageShouldMatchCustomConfig() throws Exception {
String logLogger = LogService.MAIN_LOGGER_NAME;
Level logLevel = Level.INFO;
String logMessage = "this is a log statement from " + testName.getMethodName();
LogWriter logger = this.cache.getLogger();
assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
BasicAppender.clearEvents();
logger.info(logMessage);
BasicAppender appender = BasicAppender.getInstance();
assertThat(appender).isNotNull();
assertThat(appender.events().size()).isGreaterThan(0);
LogEvent event = null;
for (LogEvent logEvent : appender.events()) {
if (logEvent.getMessage().getFormattedMessage().contains(logMessage)) {
event = logEvent;
break;
}
}
assertThat(event).isNotNull();
assertThat(event.getLoggerName()).isEqualTo(logLogger);
assertThat(event.getLevel()).isEqualTo(logLevel);
assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
assertThat(systemOutRule.getLog()).contains(logLevel.name());
assertThat(systemOutRule.getLog()).contains(logMessage);
assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
assertThat(systemOutRule.getLog()).containsPattern(defineLogStatementRegex(logLevel, logMessage));
}
use of org.apache.geode.LogWriter in project geode by apache.
the class InterestResultPolicyDUnitTest method testBug35358.
/**
* This test does the following<br>
* 1)Create client cache and region<br>
* 2)Call registerInterest with specific keys (having extra keys other than those pre-populated on
* server cache) and policy:KEYS<br>
* 3)At the end of registerInterest call, verify that only prepolulated entries are created in the
* client cache with null values (entries for keys in the keylist which are not on the server
* should not be created on the client as a result of registerInterest call)<br>
*/
@Test
public void testBug35358() {
Host host = Host.getHost(0);
LogWriter logger = getSystem().getLogWriter();
logger.fine("testBug35358 BEGIN");
Object[] objArr = new Object[2];
objArr[0] = InterestResultPolicy.KEYS;
/* registering for 5 extra keys */
objArr[1] = new Integer(PREPOPULATED_ENTRIES + 5);
vm1.invoke(() -> InterestResultPolicyDUnitTest.createClientCache(NetworkUtils.getServerHostName(host), new Integer(PORT)));
vm1.invoke(InterestResultPolicyDUnitTest.class, "registerInterest", objArr);
vm1.invoke(InterestResultPolicyDUnitTest.class, "verifyResult", objArr);
Integer cnt = (Integer) vm0.invoke(() -> InterestResultPolicyDUnitTest.getEntryCount());
assertEquals(cnt.intValue(), PREPOPULATED_ENTRIES);
logger.fine("testBug35358 END");
}
use of org.apache.geode.LogWriter in project geode by apache.
the class InterestResultPolicyDUnitTest method testPolicyKeysValues.
/**
* This test does the following<br>
* 1)Create client cache and region<br>
* 2)Call registerInterest with all keys pre-populated on server and policy:KEYS_VALUES<br>
* 3)At the end of registerInterest call, verify that all entries are created in the client cache
* with values<br>
*/
@Test
public void testPolicyKeysValues() {
LogWriter logger = getSystem().getLogWriter();
logger.fine("testPolicyKeyValues BEGIN");
Object[] objArr = new Object[2];
objArr[0] = InterestResultPolicy.KEYS_VALUES;
objArr[1] = new Integer(PREPOPULATED_ENTRIES);
Host host = Host.getHost(0);
vm1.invoke(() -> InterestResultPolicyDUnitTest.createClientCache(NetworkUtils.getServerHostName(host), new Integer(PORT)));
vm1.invoke(InterestResultPolicyDUnitTest.class, "registerInterest", objArr);
vm1.invoke(InterestResultPolicyDUnitTest.class, "verifyResult", objArr);
logger.fine("testPolicyKeyValues END");
}
use of org.apache.geode.LogWriter in project geode by apache.
the class InterestResultPolicyDUnitTest method testPolicyNone.
/**
* This test does the following<br>
* 1)Create client cache and region<br>
* 2)Call registerInterest with all keys pre-populated on server and policy:NONE<br>
* 3)At the end of registerInterest call, verify that no entries are created in the client
* cache<br>
*/
@Test
public void testPolicyNone() {
LogWriter logger = getSystem().getLogWriter();
logger.fine("testPolicyNone BEGIN");
Object[] objArr = new Object[2];
objArr[0] = InterestResultPolicy.NONE;
objArr[1] = new Integer(PREPOPULATED_ENTRIES);
Host host = Host.getHost(0);
vm1.invoke(() -> InterestResultPolicyDUnitTest.createClientCache(NetworkUtils.getServerHostName(host), new Integer(PORT)));
vm1.invoke(InterestResultPolicyDUnitTest.class, "registerInterest", objArr);
vm1.invoke(InterestResultPolicyDUnitTest.class, "verifyResult", objArr);
logger.fine("testPolicyNone END");
}
Aggregations