Skip to content
Permalink
Browse files
Server module prepared, standalone start ok
  • Loading branch information
dspavlov committed Sep 20, 2018
1 parent 5d8ddb0 commit 3027d04f16b8c478e6b198cac9eae8064a2686bd
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 96 deletions.
@@ -41,6 +41,11 @@ allprojects {

ignVer = '2.6.0'
// ignVer = '2.7.0-SNAPSHOT'

guavaVer = '26.0-jre'

//dual-licensed under the EPL v1.0 (Category B list.) and the LGPL 2.1 (category X).
logbackVer = '1.2.3'
}

repositories {
@@ -28,18 +28,16 @@ repositories {

// https://www.apache.org/legal/resolved.html#category-a
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '26.0-jre'
compile group: 'com.google.guava', name: 'guava', version: guavaVer

compile group: 'org.apache.ignite', name: 'ignite-core', version: ignVer
compile group: 'org.apache.ignite', name: 'ignite-slf4j', version: ignVer

// MIT/X11 license, category A;
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'

//dual-licensed under the EPL v1.0 (Category B list.) and the LGPL 2.1 (category X).
def lbVer = '1.2.3'
compile group: 'ch.qos.logback', name: 'logback-core', version: lbVer
compile group: 'ch.qos.logback', name: 'logback-classic', version: lbVer
compile group: 'ch.qos.logback', name: 'logback-core', version: logbackVer
compile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVer

//Apache License Version 2.0
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
@@ -23,12 +23,19 @@
import ch.qos.logback.core.rolling.RollingFileAppender;
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
import org.apache.ignite.ci.HelperConfig;
import org.apache.ignite.ci.ITcHelper;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.WALMode;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;

public class Ignite2Configurer {
static void configLogger(File workDir, String subdir) {
public static void configLogger(File workDir, String subdir) {
LoggerContext logCtx = (LoggerContext) LoggerFactory.getILoggerFactory();

PatternLayoutEncoder logEncoder = new PatternLayoutEncoder();
@@ -45,7 +52,6 @@ static void configLogger(File workDir, String subdir) {
final File logs = new File(workDir, subdir);
HelperConfig.ensureDirExist(logs);

rollingFa.setFile(new File(logs, "logfile.log").getAbsolutePath());

TimeBasedRollingPolicy logFilePolicy = new TimeBasedRollingPolicy();
logFilePolicy.setContext(logCtx);
@@ -54,7 +60,9 @@ static void configLogger(File workDir, String subdir) {
logFilePolicy.setMaxHistory(7);
logFilePolicy.start();

//todo use logFilePolicy.getActiveFileName()
final String activeFileName = logFilePolicy.getActiveFileName();

rollingFa.setFile(new File(activeFileName).getAbsolutePath());

rollingFa.setRollingPolicy(logFilePolicy);
rollingFa.start();
@@ -66,4 +74,53 @@ static void configLogger(File workDir, String subdir) {

log.addAppender(rollingFa);
}

public static void setIgniteHome(IgniteConfiguration cfg, File workDir) {
try {
cfg.setIgniteHome(workDir.getCanonicalPath());
}
catch (IOException e) {
e.printStackTrace();
cfg.setIgniteHome(workDir.getAbsolutePath());
}
}

@NotNull
public static DataRegionConfiguration getDataRegionConfiguration() {
final DataRegionConfiguration regConf = new DataRegionConfiguration()
.setPersistenceEnabled(true);

String regSzGb = System.getProperty(ITcHelper.TEAMCITY_BOT_REGIONSIZE);

if (regSzGb != null) {
try {
int szGb = Integer.parseInt(regSzGb);

String msg = "Using custom size of region: " + szGb + "Gb";
LoggerFactory.getLogger(Ignite2Configurer.class).info(msg);
System.out.println(msg);

regConf.setMaxSize(szGb * 1024L * 1024 * 1024);
}
catch (NumberFormatException e) {
e.printStackTrace();

LoggerFactory.getLogger(Ignite2Configurer.class).error("Unable to setup region", e);
}
} else {
String msg = "Using default size of region.";
LoggerFactory.getLogger(Ignite2Configurer.class).info(msg);
System.out.println(msg);
}
return regConf;
}

static DataStorageConfiguration getDataStorageConfiguration(DataRegionConfiguration regConf) {
return new DataStorageConfiguration()
.setWalMode(WALMode.LOG_ONLY)
.setWalHistorySize(1)
.setCheckpointFrequency(5 * 60 * 1000)
.setWriteThrottlingEnabled(true)
.setDefaultDataRegionConfiguration(regConf);
}
}
@@ -18,7 +18,6 @@
package org.apache.ignite.ci.db;

import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
@@ -28,8 +27,6 @@
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.ci.HelperConfig;
import org.apache.ignite.ci.ITcHelper;
import org.apache.ignite.ci.IgniteTeamcityHelper;
import org.apache.ignite.configuration.*;
import org.apache.ignite.logger.slf4j.Slf4jLogger;
import org.apache.ignite.spi.IgniteSpiContext;
@@ -46,8 +43,8 @@
*
*/
public class TcHelperDb {
/** Logger. */
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(IgniteTeamcityHelper.class);
/** Logger. */
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TcHelperDb.class);

public static void main(String[] args) {
Ignite ignite = start();
@@ -72,27 +69,20 @@ public static void main(String[] args) {

public static Ignite start() {
final File workDir = HelperConfig.resolveWorkDir();
configLogger(workDir);
Ignite2Configurer.configLogger(workDir, "tchelper_logs");

final IgniteConfiguration cfg = new IgniteConfiguration();
setWork(cfg, workDir);
Ignite2Configurer.setIgniteHome(cfg, workDir);

setupDisco(cfg);
cfg.setConsistentId("TcHelper");
cfg.setGridLogger(new Slf4jLogger());

final DataRegionConfiguration regConf = Ignite2Configurer.getDataRegionConfiguration();

final DataRegionConfiguration regConf = new DataRegionConfiguration()
.setPersistenceEnabled(true);
final DataStorageConfiguration dsCfg = Ignite2Configurer.getDataStorageConfiguration(regConf);

setupRegSize(regConf);

final DataStorageConfiguration dsCfg = new DataStorageConfiguration()
.setWalMode(WALMode.LOG_ONLY)
.setWalHistorySize(1)
.setCheckpointFrequency(5 * 60 * 1000)
.setWriteThrottlingEnabled(true)
.setDefaultDataRegionConfiguration(regConf);
dsCfg.setPageSize(4 * 1024);

cfg.setDataStorageConfiguration(dsCfg);

@@ -109,39 +99,6 @@ public static Ignite start() {
return ignite;
}

/**
* @param regConf Reg conf.
*/
private static void setupRegSize(DataRegionConfiguration regConf) {
String regSzGb = System.getProperty(ITcHelper.TEAMCITY_BOT_REGIONSIZE);

if (regSzGb != null) {
try {
int szGb = Integer.parseInt(regSzGb);

String msg = "Using custom size of region: " + szGb + "Gb";
logger.info(msg);
System.out.println(msg);

regConf.setMaxSize(szGb * 1024L * 1024 * 1024);
}
catch (NumberFormatException e) {
e.printStackTrace();

logger.error("Unable to setup region", e);
}
} else {
String msg = "Using default size of region.";
logger.info(msg);
System.out.println(msg);
}
}

private static void configLogger(File workDir) {
final String subdir = "tchelper_logs";
Ignite2Configurer.configLogger(workDir, subdir);
}

public static Ignite startClient() {
final IgniteConfiguration cfg = new IgniteConfiguration();

@@ -170,16 +127,6 @@ private static void setupSinglePortDisco(IgniteConfiguration cfg, int locPort) {
cfg.setDiscoverySpi(spi);
}

private static void setWork(IgniteConfiguration cfg, File workDir) {
try {
cfg.setIgniteHome(workDir.getCanonicalPath());
}
catch (IOException e) {
e.printStackTrace();
cfg.setIgniteHome(workDir.getAbsolutePath());
}
}

public static void stop(Ignite ignite) {
Ignition.stop(ignite.name(), false);
}
@@ -64,5 +64,5 @@ dependencies {
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyVer
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVer

compile group: 'com.google.guava', name: 'guava', version: '22.0'
compile group: 'com.google.guava', name: 'guava', version: guavaVer
}
@@ -26,7 +26,7 @@ repositories {
mavenLocal()
}

mainClassName = 'org.apache.ignite.ci.TcHelperDbLauncher'
mainClassName = 'org.apache.ignite.ci.TcBotIgniteServerLauncher'
applicationDefaultJvmArgs = ["-Dteamcity.helper.home=../work",
"-Dteamcity.bot.regionsize=16", // 16g Durable Memory region
"-server",
@@ -51,4 +51,11 @@ dependencies {
transitive = false
}

compile group: 'com.google.guava', name: 'guava', version: guavaVer

compile group: 'ch.qos.logback', name: 'logback-core', version: logbackVer
compile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVer

compile group: 'org.apache.ignite', name: 'ignite-core', version: ignVer
compile group: 'org.apache.ignite', name: 'ignite-slf4j', version: ignVer
}
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.ci;

import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.ci.db.Ignite2Configurer;
import org.apache.ignite.ci.db.TcHelperDb;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.WALMode;
import org.apache.ignite.logger.slf4j.Slf4jLogger;

import java.io.File;
import java.io.IOException;

public class TcBotIgniteServerLauncher {
public static void main(String[] args) throws IOException {
final File workDir = HelperConfig.resolveWorkDir();
Ignite2Configurer.configLogger(workDir, "tcbot_srv_logs");

final IgniteConfiguration cfg = new IgniteConfiguration();
Ignite2Configurer.setIgniteHome(cfg, workDir);
cfg.setWorkDirectory(new File(cfg.getIgniteHome(), "tcbot_srv").getCanonicalPath());

/*
setupDisco(cfg);*/
cfg.setConsistentId("tcbot");
cfg.setGridLogger(new Slf4jLogger());
System.err.println("Hello");


final DataRegionConfiguration regConf = Ignite2Configurer.getDataRegionConfiguration();

final DataStorageConfiguration dsCfg = new DataStorageConfiguration()
.setWalMode(WALMode.LOG_ONLY)
.setWalHistorySize(1)
.setCheckpointFrequency(5 * 60 * 1000)
.setWriteThrottlingEnabled(true)
.setDefaultDataRegionConfiguration(regConf);

cfg.setDataStorageConfiguration(dsCfg);

System.out.println("Starting Ignite Server Node");

final Ignite ignite = Ignition.start(cfg);

System.out.println("Activating Ignite Server Node");

ignite.cluster().active(true);

System.out.println("Activate Completed");
}
}

This file was deleted.

0 comments on commit 3027d04

Please sign in to comment.