You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/10/11 10:27:02 UTC

[ignite-teamcity-bot] branch ignite-9848-load-all-builds updated: IGNITE-9848: Empty entity created

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-9848-load-all-builds
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/ignite-9848-load-all-builds by this push:
     new 6c1a5aa  IGNITE-9848: Empty entity created
6c1a5aa is described below

commit 6c1a5aa04cfdda41a7c8879dc39dc8ea45883195
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Oct 11 13:26:46 2018 +0300

    IGNITE-9848: Empty entity created
---
 .../org/apache/ignite/ci/tcmodel/result/Build.java |  2 +-
 .../ci/teamcity/ignited/BuildRefCompacted.java     | 48 +++++++++++++++++-----
 .../ignite/ci/teamcity/ignited/BuildRefDao.java    | 17 +++++---
 .../ci/teamcity/ignited/FatBuildCompacted.java     | 42 +++++++++++++++++++
 .../ignited/IgnitedTcInMemoryIntegrationTest.java  |  1 +
 5 files changed, 92 insertions(+), 18 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
index 9c6a9cd..443610c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/result/Build.java
@@ -83,7 +83,7 @@ public class Build extends BuildRef implements IVersionedEntity {
         return buildType == null ? null : buildType.getName();
     }
 
-    public String getFinishDateDdMmYyyy() throws ParseException {
+    public String getFinishDateDdMmYyyy() {
         Date parse = getFinishDate();
         return new SimpleDateFormat("dd.MM.yyyy").format(parse);
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
index 6494e56..77eec6d 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefCompacted.java
@@ -17,14 +17,25 @@
 package org.apache.ignite.ci.teamcity.ignited;
 
 import com.google.common.base.Objects;
+import org.apache.ignite.ci.db.Persisted;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 
+@Persisted
 public class BuildRefCompacted {
-    int id = -1;
-    int buildTypeId = -1;
-    int branchName = -1;
-    int status = -1;
-    int state = -1;
+    /** Build Id without modifications, -1 if it is null. */
+    private int id = -1;
+
+    /** Compacter identifier for string 'Build type id'. */
+    private int buildTypeId = -1;
+
+    /** Compacter identifier for string 'Branch name'. */
+    private int branchName = -1;
+
+    /** Compacter identifier for string 'Status'. */
+    private int status = -1;
+
+    /** Compacter identifier for string 'State'. */
+    private int state = -1;
 
     /**
      * Default constructor.
@@ -33,15 +44,15 @@ public class BuildRefCompacted {
     }
 
     /**
-     * @param compacter Compacter.
+     * @param compactor Compactor.
      * @param ref Reference.
      */
-    public BuildRefCompacted(IStringCompactor compacter, BuildRef ref) {
+    public BuildRefCompacted(IStringCompactor compactor, BuildRef ref) {
         id = ref.getId() == null ? -1 : ref.getId();
-        buildTypeId = compacter.getStringId(ref.buildTypeId());
-        branchName = compacter.getStringId(ref.branchName());
-        status = compacter.getStringId(ref.status());
-        state = compacter.getStringId(ref.state());
+        buildTypeId = compactor.getStringId(ref.buildTypeId());
+        branchName = compactor.getStringId(ref.branchName());
+        status = compactor.getStringId(ref.status());
+        state = compactor.getStringId(ref.state());
     }
 
     /**
@@ -77,4 +88,19 @@ public class BuildRefCompacted {
     @Override public int hashCode() {
         return Objects.hashCode(id, buildTypeId, branchName, status, state);
     }
+
+    /** */
+    public int id() {
+        return id;
+    }
+
+    /** */
+    public int buildTypeId() {
+        return buildTypeId;
+    }
+
+    /** */
+    public int branchName() {
+        return branchName;
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
index cfcd3bd..51df04f 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
@@ -33,10 +33,11 @@ import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.ci.db.TcHelperDb;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.jetbrains.annotations.NotNull;
 
 public class BuildRefDao {
-    /** Cache name*/
+    /** Cache name */
     public static final String TEAMCITY_BUILD_CACHE_NAME = "teamcityBuild";
 
     /** Ignite provider. */
@@ -49,8 +50,8 @@ public class BuildRefDao {
     @Inject private IStringCompactor compactor;
 
     public void init () {
-        Ignite ignite = igniteProvider.get();
-        buildsCache = ignite.getOrCreateCache(TcHelperDb.getCacheV2Config(TEAMCITY_BUILD_CACHE_NAME));
+        CacheConfiguration<Long, BuildRefCompacted> cfg = TcHelperDb.getCacheV2Config(TEAMCITY_BUILD_CACHE_NAME);
+        buildsCache = igniteProvider.get().getOrCreateCache(cfg);
     }
 
     @NotNull protected Stream<BuildRefCompacted> compactedBuildsForServer(long srvIdMaskHigh) {
@@ -59,6 +60,10 @@ public class BuildRefDao {
             .map(javax.cache.Cache.Entry::getValue);
     }
 
+    /**
+     * @param srvIdMaskHigh Server id mask high.
+     * @param ghData Gh data.
+     */
     public int saveChunk(long srvIdMaskHigh, List<BuildRef> ghData) {
         Set<Long> ids = ghData.stream().map(BuildRef::getId)
             .filter(Objects::nonNull)
@@ -73,7 +78,7 @@ public class BuildRefDao {
             .collect(Collectors.toList());
 
         for (BuildRefCompacted next : collect) {
-            long cacheKey = buildIdToCacheKey(srvIdMaskHigh, next.id);
+            long cacheKey = buildIdToCacheKey(srvIdMaskHigh, next.id());
             BuildRefCompacted buildPersisted = existingEntries.get(cacheKey);
 
             if (buildPersisted == null || !buildPersisted.equals(next))
@@ -112,8 +117,8 @@ public class BuildRefDao {
             return Collections.emptyList();
 
         return compactedBuildsForServer(srvIdMaskHigh)
-            .filter(e -> e.buildTypeId == (int)buildTypeIdId)
-            .filter(e -> e.branchName == (int)bracnhNameQryId)
+            .filter(e -> e.buildTypeId() == buildTypeIdId)
+            .filter(e -> e.branchName() == bracnhNameQryId)
             .map(compacted -> compacted.toBuildRef(compactor))
             .collect(Collectors.toList());
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java
new file mode 100644
index 0000000..10fd975
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/FatBuildCompacted.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import org.apache.ignite.ci.analysis.IVersionedEntity;
+import org.apache.ignite.ci.db.Persisted;
+
+/**
+ *
+ */
+@Persisted
+public class FatBuildCompacted extends BuildRefCompacted implements IVersionedEntity {
+    /** Latest version. */
+    private static final int LATEST_VERSION = 0;
+
+    /** Entity fields version. */
+    private short _ver;
+
+    /** {@inheritDoc} */
+    @Override public int version() {
+        return _ver;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int latestVersion() {
+        return LATEST_VERSION;
+    }
+}
diff --git a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
index 233f918..0cd34d5 100644
--- a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
+++ b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
@@ -101,6 +101,7 @@ public class IgnitedTcInMemoryIntegrationTest {
         String buildTypeId = "IgniteTests24Java8_RunAll";
         String branchName = "<default>";
         List<BuildRef> hist = srv.getBuildHistory(buildTypeId, branchName);
+        //todo mult branches including pull/4926/head
 
         assertTrue(!hist.isEmpty());