Skip to content

Commit

Permalink
Code style, comments, and removal of created by comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dspavlov committed Aug 17, 2018
1 parent 7f89dab commit cfc5158
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import static com.google.common.base.Strings.isNullOrEmpty;

/**
* Created by Дмитрий on 21.07.2017
* TC Helper Config access stuff.
*/
public class HelperConfig {
public static final String CONFIG_FILE_NAME = "auth.properties";
Expand All @@ -53,17 +53,17 @@ public class HelperConfig {
public static final String LOGS = "logs";
public static final String ENDL = String.format("%n");

public static Properties loadAuthProperties(File workDir, String configFileName) {
public static Properties loadAuthProperties(File workDir, String cfgFileName) {
try {
return loadAuthPropertiesX(workDir, configFileName);
return loadAuthPropertiesX(workDir, cfgFileName);
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}

private static Properties loadAuthPropertiesX(File workDir, String configFileName) throws IOException {
File file = new File(workDir, configFileName);
private static Properties loadAuthPropertiesX(File workDir, String cfgFileName) throws IOException {
File file = new File(workDir, cfgFileName);
if (!(file.exists())) {

try (FileWriter writer = new FileWriter(file)) {
Expand All @@ -78,16 +78,16 @@ private static Properties loadAuthPropertiesX(File workDir, String configFileNam
}

private static Properties loadProps(File file) throws IOException {
Properties properties = new Properties();
Properties props = new Properties();

try (FileReader reader = new FileReader(file)) {
properties.load(reader);
props.load(reader);
}

return properties;
return props;
}

public static String prepareConfigName(String tcName) {
static String prepareConfigName(String tcName) {
return prefixedWithServerName(tcName, CONFIG_FILE_NAME);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.ignite.ci;

/**
* Created by Дмитрий on 25.02.2018.
* Combination of REST data and persisted statistics.
*/
public interface IAnalyticsEnabledTeamcity extends ITeamcity, ITcAnalytics {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Collection;

/**
* Created by Дмитрий on 25.02.2018
* Teamcity Bot main interface
*/
public interface ITcHelper {
IssuesStorage issues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import static org.apache.ignite.ci.BuildChainProcessor.normalizeBranch;

/**
* Created by dpavlov on 03.08.2017
*
*/
public class IgnitePersistentTeamcity implements IAnalyticsEnabledTeamcity, ITeamcity, ITcAnalytics {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
import static org.apache.ignite.ci.HelperConfig.ensureDirExist;

/**
* Created by Дмитрий on 21.07.2017.
*
* Class for access to Teamcity REST API without any caching.
*
* See more info about API
* https://confluence.jetbrains.com/display/TCD10/REST+API
*/
public class IgniteTeamcityHelper implements ITeamcity {
/** Logger. */
private static final Logger logger = LoggerFactory.getLogger(IgniteTeamcityHelper.class);


public static final String TEAMCITY_HELPER_HOME = "teamcity.helper.home";
private Executor executor;
private final File logsDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
import java.util.concurrent.atomic.AtomicBoolean;

/**
* Created by Дмитрий on 25.02.2018
* TC Bot implementation
*/
public class TcHelper implements ITcHelper {
/** Stop guard. */
private AtomicBoolean stop = new AtomicBoolean();

private final Cache<String, IAnalyticsEnabledTeamcity> servers
private final Cache<String, IAnalyticsEnabledTeamcity> srvs
= CacheBuilder.<String, String>newBuilder()
.maximumSize(100)
.expireAfterAccess(16, TimeUnit.MINUTES)
Expand All @@ -66,23 +67,23 @@ public TcHelper(Ignite ignite) {
detector = new IssueDetector(ignite, issuesStorage, userAndSessionsStorage);
}

@Override
public IssuesStorage issues() {
/** {@inheritDoc} */
@Override public IssuesStorage issues() {
return issuesStorage;
}

@Override
public IssueDetector issueDetector() {
/** {@inheritDoc} */
@Override public IssueDetector issueDetector() {
return detector;
}

@Override
public IAnalyticsEnabledTeamcity server(String srvId, @Nullable ICredentialsProv prov) {
/** {@inheritDoc} */
@Override public IAnalyticsEnabledTeamcity server(String srvId, @Nullable ICredentialsProv prov) {
if (stop.get())
throw new IllegalStateException("Shutdown");

Callable<IAnalyticsEnabledTeamcity> callable = () -> {
IgnitePersistentTeamcity teamcity = new IgnitePersistentTeamcity(ignite,
Callable<IAnalyticsEnabledTeamcity> call = () -> {
IAnalyticsEnabledTeamcity teamcity = new IgnitePersistentTeamcity(ignite,
Strings.emptyToNull(srvId));

teamcity.setExecutor(getService());
Expand All @@ -99,7 +100,7 @@ public IAnalyticsEnabledTeamcity server(String srvId, @Nullable ICredentialsProv

IAnalyticsEnabledTeamcity teamcity;
try {
teamcity = servers.get(fullKey, callable);
teamcity = srvs.get(fullKey, call);
}
catch (ExecutionException e) {
throw ExceptionUtil.propagateException(e);
Expand All @@ -108,18 +109,17 @@ public IAnalyticsEnabledTeamcity server(String srvId, @Nullable ICredentialsProv
return teamcity;
}

@Override
public ITcAnalytics tcAnalytics(String serverId) {
return server(serverId, null);
/** {@inheritDoc} */
@Override public ITcAnalytics tcAnalytics(String srvId) {
return server(srvId, null);
}

@Override
public UserAndSessionsStorage users() {
/** {@inheritDoc} */
@Override public UserAndSessionsStorage users() {
return userAndSessionsStorage;
}

@Override
public String primaryServerId() {
@Override public String primaryServerId() {
return "apache"; //todo remove
}

Expand All @@ -138,7 +138,7 @@ private BranchesTracked getTrackedBranches() {

public void close() {
if (stop.compareAndSet(false, true)) {
servers.asMap().values().forEach(v -> {
srvs.asMap().values().forEach(v -> {
try {
v.close();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.jetbrains.annotations.NotNull;

/**
* Created by dpavlov on 20.09.2017
*
*/
public class FullChainRunCtx {
private final boolean fakeStub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.ignite.ci.logs.handlers.ThreadDumpInMemoryHandler;

/**
* Created by Дмитрий on 24.03.2018
*
*/
public class LogCheckTask {
LogCheckResult result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.ignite.ci.db.Persisted;

/**
* Created by dpavlov on 09.08.2017.
*
*/
@Persisted
public class SuiteInBranch implements Comparable<SuiteInBranch> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@
/**
*/
public enum ProcessLogsMode {
DISABLED, SUITE_NOT_COMPLETE, ALL
/** Don't parse build logs. */
DISABLED,

/** Parse logs if suite not completed. */
SUITE_NOT_COMPLETE,

/** Always parse logs. */
ALL
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.ignite.configuration.CacheConfiguration;

/**
* Created by Дмитрий on 11.02.2018
* Migrations to be applied to each TC related caches.
*/
public class DbMigrations {
public static final String DONE_MIGRATIONS = "doneMigrations";
Expand All @@ -48,7 +48,6 @@ public class DbMigrations {
public static final String BUILD_RESULTS = "buildResults";
public static final String TESTS_COUNT_7700 = ",count:7700";


//V1 caches, 1024 parts
@Deprecated
public static final String RUN_STAT_CACHE = "runStat";
Expand All @@ -57,9 +56,9 @@ public class DbMigrations {
private final String serverId;
private IgniteCache<String, Object> doneMigrations;

public DbMigrations(Ignite ignite, String serverId) {
public DbMigrations(Ignite ignite, String srvId) {
this.ignite = ignite;
this.serverId = serverId;
this.serverId = srvId;
}

public static String removeCountFromRef(String href) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import static org.apache.ignite.ci.web.Launcher.waitStopSignal;

/**
* Created by dpavlov on 04.08.2017
*
*/
public class TcHelperDb {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.io.File;

/**
* Created by dpavlov on 24.07.2017
*
*/
public interface ILineHandler extends AutoCloseable {
public void accept(String line, File file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@

package org.apache.ignite.ci.logs;

/**
*
*/
public interface ILogProductSpecific {
boolean isTestStarting(String line);
/**
* @param line Line.
*/
public boolean isTestStarting(String line);

boolean isTestStopping(String line);
/**
* @param line Line.
*/
public boolean isTestStopping(String line);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@

package org.apache.ignite.ci.logs;

/**
* Ignite specific logic related to build logs.
*/
public class LogIgniteSpecific implements ILogProductSpecific {

/** Starting test. */
private static final String STARTING_TEST = ">>> Starting test: ";
/** Test name end. */
private static final String TEST_NAME_END = " <<<";
/** Stopping test. */
private static final String STOPPING_TEST = ">>> Stopping test: ";

public static final String STOPPING_TEST = ">>> Stopping test: ";

/** {@inheritDoc} */
@Override public boolean isTestStarting(String line) {
return line.contains(STARTING_TEST) && line.contains(TEST_NAME_END);
}

/** {@inheritDoc} */
@Override public boolean isTestStopping(String line) {
return line.contains(STOPPING_TEST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.ignite.ci.logs;

/**
* Created by Дмитрий on 24.03.2018
*
*/
//todo make non static
//todo include test name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,30 @@
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;
import javax.annotation.concurrent.NotThreadSafe;
import org.apache.ignite.ci.IgniteTeamcityHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created by dpavlov on 24.07.2017.
*
* Use one instance per one file, class is statefull and not thread safe
* Use one instance per one file, class is stateful.
*/
@NotThreadSafe
public class LogsAnalyzer implements Function<File, File> {
/** Logger. */
private static final Logger logger = LoggerFactory.getLogger(LogsAnalyzer.class);

/** Line handlers list. */
private final List<ILineHandler> lineHandlersList;

/**
* @param lineHandlers Line handlers.
*/
public LogsAnalyzer(ILineHandler... lineHandlers) {
lineHandlersList = Arrays.asList(lineHandlers);
}

/** {@inheritDoc} */
@Override public File apply(File file) {
try (Stream<String> lines = Files.lines(file.toPath(), StandardCharsets.UTF_8)) {
lines.forEach(line -> lineHandlersList.forEach(h -> h.accept(line, file)));
Expand All @@ -52,12 +62,13 @@ public LogsAnalyzer(ILineHandler... lineHandlers) {
return file;
}

private void closeSilent(ILineHandler handler) {
private void closeSilent(ILineHandler hnd) {
try {
handler.close();
hnd.close();
}
catch (Exception e) {
e.printStackTrace();
logger.error("Problem with line handler release: " + e.getMessage(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public TestLogCheckResult curTest() {
return tests.computeIfAbsent(curName, k -> new TestLogCheckResult());
}

/** {@inheritDoc} */
@Override public void close() throws Exception {
if (saveLastTestToFile && currentTestName != null && !curTestLog.isEmpty())
dumpCurrentToFile("lastStartedTest_");
Expand Down
Loading

0 comments on commit cfc5158

Please sign in to comment.