use of org.apache.ignite.logger.log4j2.Log4J2Logger in project YCSB by brianfrankcooper.
the class IgniteClientTest method beforeTest.
@BeforeClass
public static void beforeTest() throws IgniteCheckedException {
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(SERVER_NODE_NAME);
igcfg.setClientMode(false);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> adders = new LinkedHashSet<>();
adders.add(HOST + ":" + PORTS);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(adders);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
CacheConfiguration ccfg = new CacheConfiguration().setName(DEFAULT_CACHE_NAME);
igcfg.setCacheConfiguration(ccfg);
Log4J2Logger logger = new Log4J2Logger(IgniteClientTest.class.getClassLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
cluster = Ignition.start(igcfg);
cluster.active();
}
use of org.apache.ignite.logger.log4j2.Log4J2Logger in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method beforeTest.
/**
*/
@BeforeClass
public static void beforeTest() throws IgniteCheckedException {
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(SERVER_NODE_NAME);
igcfg.setClientMode(false);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> adders = new LinkedHashSet<>();
adders.add(HOST + ":" + PORTS);
QueryEntity qe = new QueryEntity("java.lang.String", "UserTableType").addQueryField("ycsb_key", "java.lang.String", null).addQueryField("field0", "java.lang.String", null).addQueryField("field1", "java.lang.String", null).addQueryField("field2", "java.lang.String", null).addQueryField("field3", "java.lang.String", null).addQueryField("field4", "java.lang.String", null).addQueryField("field5", "java.lang.String", null).addQueryField("field6", "java.lang.String", null).addQueryField("field7", "java.lang.String", null).addQueryField("field8", "java.lang.String", null).addQueryField("field9", "java.lang.String", null).setKeyFieldName("ycsb_key");
qe.setTableName("usertable");
CacheConfiguration ccfg = new CacheConfiguration().setQueryEntities(Collections.singleton(qe)).setName(DEFAULT_CACHE_NAME);
igcfg.setCacheConfiguration(ccfg);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(adders);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
Log4J2Logger logger = new Log4J2Logger(IgniteSqlClientTest.class.getClassLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
cluster = Ignition.start(igcfg);
cluster.active();
}
use of org.apache.ignite.logger.log4j2.Log4J2Logger in project ignite by apache.
the class Logging method log4j2.
void log4j2() throws IgniteCheckedException {
// tag::log4j2[]
IgniteConfiguration cfg = new IgniteConfiguration();
IgniteLogger log = new Log4J2Logger("log4j2-config.xml");
cfg.setGridLogger(log);
// Start a node.
try (Ignite ignite = Ignition.start(cfg)) {
ignite.log().info("Info Message Logged!");
}
// end::log4j2[]
}
use of org.apache.ignite.logger.log4j2.Log4J2Logger in project YCSB by brianfrankcooper.
the class IgniteAbstractClient method init.
/**
* Initialize any state for this DB. Called once per DB instance; there is one
* DB instance per client thread.
*/
@Override
public void init() throws DBException {
// Keep track of number of calls to init (for later cleanup)
INIT_COUNT.incrementAndGet();
// cluster/session instance for all the threads.
synchronized (INIT_COUNT) {
// Check if the cluster has already been initialized
if (cluster != null) {
return;
}
try {
debug = Boolean.parseBoolean(getProperties().getProperty("debug", "false"));
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(CLIENT_NODE_NAME);
String host = getProperties().getProperty(HOSTS_PROPERTY);
if (host == null) {
throw new DBException(String.format("Required property \"%s\" missing for Ignite Cluster", HOSTS_PROPERTY));
}
String ports = getProperties().getProperty(PORTS_PROPERTY, PORTS_DEFAULTS);
if (ports == null) {
throw new DBException(String.format("Required property \"%s\" missing for Ignite Cluster", PORTS_PROPERTY));
}
System.setProperty("IGNITE_QUIET", "false");
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> addrs = new LinkedHashSet<>();
addrs.add(host + ":" + ports);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(addrs);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
igcfg.setClientMode(true);
Log4J2Logger logger = new Log4J2Logger(this.getClass().getClassLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
log.info("Start Ignite client node.");
cluster = Ignition.start(igcfg);
log.info("Activate Ignite cluster.");
cluster.active(true);
cache = cluster.cache(DEFAULT_CACHE_NAME).withKeepBinary();
if (cache == null) {
throw new DBException(new IgniteCheckedException("Failed to find cache " + DEFAULT_CACHE_NAME));
}
} catch (Exception e) {
throw new DBException(e);
}
}
// synchronized
}
Aggregations