[GitHub] SomeFire commented on a change in pull request #78: IGNITE-10203 Support for alternative configurations for PR testing

2018-11-23 Thread GitBox
SomeFire commented on a change in pull request #78: IGNITE-10203 Support for 
alternative configurations for PR testing
URL: https://github.com/apache/ignite-teamcity-bot/pull/78#discussion_r235949008
 
 

 ##
 File path: 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/buildtype/ParametersCompacted.java
 ##
 @@ -0,0 +1,134 @@
+/*
+ * 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.teamcity.ignited.buildtype;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import org.apache.ignite.ci.tcmodel.conf.bt.Parameters;
+import org.apache.ignite.ci.tcmodel.conf.bt.Property;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.apache.ignite.internal.util.GridIntList;
+
+public class ParametersCompacted {
+private GridIntList keys;
+private GridIntList values;
+
+/**
+ * Default constructor.
+ */
+public ParametersCompacted() {
+}
+
+/**
+ * @param compactor Compactor.
+ * @param ref Reference.
+ */
+public ParametersCompacted(IStringCompactor compactor, List ref) 
{
+final int size = ref.size();
+keys = new GridIntList(size);
+values = new GridIntList(size);
+for (Property next : ref) {
+final String name = next.name();
+if (Strings.isNullOrEmpty(name))
+continue;
+
+final String value = next.getValue();
+if (Strings.isNullOrEmpty(value))
+continue;
+final int val = compactor.getStringId(value);
+final int stringId = compactor.getStringId(name);
+
+keys.add(stringId);
+values.add(val);
+}
+}
+
+public Parameters toParameters(IStringCompactor compactor) {
+List properties = null;
+
+if (keys.size() > 0) {
+properties = new ArrayList<>();
+
+final int size = keys.size();
+for (int i = 0; i < size; i++) {
+if (i >= values.size())
 
 Review comment:
   Move check inside `for` statement.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] SomeFire commented on a change in pull request #78: IGNITE-10203 Support for alternative configurations for PR testing

2018-11-23 Thread GitBox
SomeFire commented on a change in pull request #78: IGNITE-10203 Support for 
alternative configurations for PR testing
URL: https://github.com/apache/ignite-teamcity-bot/pull/78#discussion_r235949213
 
 

 ##
 File path: 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/buildtype/ParametersCompacted.java
 ##
 @@ -0,0 +1,134 @@
+/*
+ * 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.teamcity.ignited.buildtype;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import org.apache.ignite.ci.tcmodel.conf.bt.Parameters;
+import org.apache.ignite.ci.tcmodel.conf.bt.Property;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.apache.ignite.internal.util.GridIntList;
+
+public class ParametersCompacted {
+private GridIntList keys;
+private GridIntList values;
+
+/**
+ * Default constructor.
+ */
+public ParametersCompacted() {
+}
+
+/**
+ * @param compactor Compactor.
+ * @param ref Reference.
+ */
+public ParametersCompacted(IStringCompactor compactor, List ref) 
{
+final int size = ref.size();
+keys = new GridIntList(size);
+values = new GridIntList(size);
+for (Property next : ref) {
+final String name = next.name();
+if (Strings.isNullOrEmpty(name))
+continue;
+
+final String value = next.getValue();
+if (Strings.isNullOrEmpty(value))
+continue;
+final int val = compactor.getStringId(value);
+final int stringId = compactor.getStringId(name);
+
+keys.add(stringId);
+values.add(val);
+}
+}
+
+public Parameters toParameters(IStringCompactor compactor) {
+List properties = null;
+
+if (keys.size() > 0) {
+properties = new ArrayList<>();
+
+final int size = keys.size();
+for (int i = 0; i < size; i++) {
+if (i >= values.size())
 
 Review comment:
   And empty line before `for`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] SomeFire commented on a change in pull request #78: IGNITE-10203 Support for alternative configurations for PR testing

2018-11-23 Thread GitBox
SomeFire commented on a change in pull request #78: IGNITE-10203 Support for 
alternative configurations for PR testing
URL: https://github.com/apache/ignite-teamcity-bot/pull/78#discussion_r235948717
 
 

 ##
 File path: 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
 ##
 @@ -308,6 +330,120 @@ else if (midValStartDate.before(key))
 return chains;
 }
 
+/**
+ * Actualize saved list of composite suites for project.
+ *
+ * @param projectId Project id.
+ */
+private void actualizeSavedCompositeBuildTypesIds(String projectId) {
+if (projectId.equals(DEFAULT_PROJECT_ID)) {
+compositeBuildTypesIdsForDefaultProject =
+
fatBuildTypeDao.compositeBuildTypesIdsSortedByBuildNumberCounter(srvIdMaskHigh, 
projectId);
+}
+}
+
+/** {@inheritDoc} */
+@Override public List 
getCompositeBuildTypesIdsSortedByBuildNumberCounter(String projectId) {
+ensureActualizeBuildTypeRefsRequested();
+ensureActualizeBuildTypesRequested();
+
+return projectId.equals(DEFAULT_PROJECT_ID) ? 
compositeBuildTypesIdsForDefaultProject :
+
fatBuildTypeDao.compositeBuildTypesIdsSortedByBuildNumberCounter(srvIdMaskHigh, 
projectId);
+}
+
+/** {@inheritDoc} */
+@Override public List 
getAllBuildTypesCompacted(String projectId) {
+ensureActualizeBuildTypeRefsRequested();
+
+return buildTypeRefDao.buildTypesCompacted(srvIdMaskHigh, projectId);
+}
+
+/**
+ * Ensure actualize BuildTypeRefs requested. Add this task to scheduler.
+ */
+private void ensureActualizeBuildTypeRefsRequested() {
+scheduler.sheduleNamed(taskName("actualizeAllBuildTypeRefs"),
+this::reindexBuildTypeRefs, 4, TimeUnit.HOURS);
+}
+
+/**
+ *Ensure actualize BuildTypes requested. Add this task to scheduler.
+ */
+private void ensureActualizeBuildTypesRequested() {
+scheduler.sheduleNamed(taskName("actualizeAllBuildTypes"),
+this::reindexBuildTypes, 24, TimeUnit.HOURS);
+}
+
+/**
+ * Re-index all references to "IgniteTests24Java8" suites.
+ */
+private void reindexBuildTypeRefs() {
+runActualizeBuildTypeRefs(DEFAULT_PROJECT_ID);
+}
+
+/**
+ * Re-index all "IgniteTests24Java8" suites.
+ */
+private void reindexBuildTypes() {
+runActualizeBuildTypes(DEFAULT_PROJECT_ID);
+}
+
+/**
+ * Re-index all project suites.
+ *
+ * @param projectId Project id.
+ * @return Statistics with the number of updated and requested buildTypes.
+ */
+@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"})
+@MonitoredTask(name = "Reindex BuildTypes (projectId)", nameExtArgsIndexes 
= {0})
+@AutoProfiling
+protected String runActualizeBuildTypes(String projectId) {
+List buildTypeIds = 
buildTypeRefDao.buildTypeIds(srvIdMaskHigh, projectId);
+
+int updated = 0;
+
+for (String buildTypeId : buildTypeIds) {
+
+BuildType buildType = conn.getBuildType(buildTypeId);
+
+FatBuildTypeCompacted existingBuildType = 
fatBuildTypeDao.getFatBuildType(srvIdMaskHigh, buildTypeId);
+
+if (fatBuildTypeDao.saveBuildType(srvIdMaskHigh, buildType, 
existingBuildType) != null)
+updated++;
+}
+
+if (updated != 0)
+actualizeSavedCompositeBuildTypesIds(projectId);
+
+return "BuildTypes updated " + updated + " from " + 
buildTypeIds.size() + " requested";
+}
+
+/**
+ * Re-index all references to project suites.
+ *
+ * @param projectId Project id.
+ * @return Statistics with the number of updated and requested 
buildTypeRefs.
+ */
+@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"})
+@MonitoredTask(name = "Reindex BuildTypeRefs (projectId)", 
nameExtArgsIndexes = {0})
+@AutoProfiling
+protected String runActualizeBuildTypeRefs(String projectId) {
+List tcData = conn.getBuildTypes(projectId);
+
+Set buildsUpdated = buildTypeRefDao.saveChunk(srvIdMaskHigh, 
tcData);
+
+Set removedBuildTypes = 
buildTypeRefDao.markMissingBuildsAsRemoved(srvIdMaskHigh,
+
tcData.stream().map(BuildTypeRef::getId).collect(Collectors.toList()), 
projectId);
+
+if (!(buildsUpdated.isEmpty() && removedBuildTypes.isEmpty())) {
 
 Review comment:
   Remove braces.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] SomeFire commented on a change in pull request #78: IGNITE-10203 Support for alternative configurations for PR testing

2018-11-23 Thread GitBox
SomeFire commented on a change in pull request #78: IGNITE-10203 Support for 
alternative configurations for PR testing
URL: https://github.com/apache/ignite-teamcity-bot/pull/78#discussion_r235915862
 
 

 ##
 File path: 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
 ##
 @@ -57,7 +54,12 @@
 @Deprecated
 long DEFAULT_BUILDS_COUNT = 1000;
 
-CompletableFuture> getProjectSuites(String projectId);
+/** {@inheritDoc} */
+@Override default List getBuildTypes(String projectId) {
+return FutureUtil.getResult(getProjectSuites(projectId));
+}
+
+CompletableFuture> getProjectSuites(String projectId);
 
 Review comment:
   Missed javadocs.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services