Search in sources :

Example 1 with Log4J2Logger

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();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Log4J2Logger(org.apache.ignite.logger.log4j2.Log4J2Logger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) BeforeClass(org.junit.BeforeClass)

Example 2 with Log4J2Logger

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();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) QueryEntity(org.apache.ignite.cache.QueryEntity) Log4J2Logger(org.apache.ignite.logger.log4j2.Log4J2Logger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) BeforeClass(org.junit.BeforeClass)

Example 3 with Log4J2Logger

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[]
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite) IgniteLogger(org.apache.ignite.IgniteLogger) Log4J2Logger(org.apache.ignite.logger.log4j2.Log4J2Logger)

Example 4 with Log4J2Logger

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
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DBException(site.ycsb.DBException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Log4J2Logger(org.apache.ignite.logger.log4j2.Log4J2Logger) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DBException(site.ycsb.DBException) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Log4J2Logger (org.apache.ignite.logger.log4j2.Log4J2Logger)4 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)3 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)3 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 BeforeClass (org.junit.BeforeClass)2 LinkedHashSet (java.util.LinkedHashSet)1 Ignite (org.apache.ignite.Ignite)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 DBException (site.ycsb.DBException)1