dspavlov commented on a change in pull request #89: IGNITE-10454 Create page 
with muted tests
URL: https://github.com/apache/ignite-teamcity-bot/pull/89#discussion_r239939993
 
 

 ##########
 File path: 
ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcmodel/mute/MuteDao.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.tcmodel.mute;
+
+import com.google.common.base.Preconditions;
+import java.util.Set;
+import javax.inject.Inject;
+import javax.inject.Provider;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.ci.db.TcHelperDb;
+import org.apache.ignite.ci.di.AutoProfiling;
+import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
+import org.apache.ignite.internal.util.typedef.F;
+
+/**
+ *
+ */
+public class MuteDao {
+    /** Cache name. */
+    public static final String TEAMCITY_MUTE_CACHE_NAME = "teamcityMute";
+
+    /** Ignite provider. */
+    @Inject private Provider<Ignite> igniteProvider;
+
+    /** Builds cache. */
+    private IgniteCache<Long, MutesCompacted> muteCache;
+
+    /** Compactor. */
+    @Inject private IStringCompactor compactor;
+
+    /**
+     *
+     */
+    public void init() {
+        muteCache = 
igniteProvider.get().getOrCreateCache(TcHelperDb.getCacheV2Config(TEAMCITY_MUTE_CACHE_NAME));
+    }
+
+    /**
+     * @param srvIdMaskHigh Server id mask high.
+     * @param projectId Build id.
+     */
+    @AutoProfiling
+    public Mutes getMutes(int srvIdMaskHigh, String projectId) {
+        Preconditions.checkNotNull(muteCache, "init() was not called");
+
+        MutesCompacted compacted = 
muteCache.get(projectIdToCacheKey(srvIdMaskHigh, projectId));
+
+        return compacted != null ? compacted.toMutes(compactor) : new Mutes();
+    }
+
+    /**
+     * Combine server and project into key for storage.
+     *
+     * @param srvIdMaskHigh Server id mask high.
+     * @param projectId Build type id.
+     * @return Key from server-project pair.
+     */
+    public static long projectIdToCacheKey(long srvIdMaskHigh, String 
projectId) {
+        return (long)projectId.hashCode() | srvIdMaskHigh << 32;
+    }
+
+    /**
+     * Save small part of loaded mutes.
+     *
+     * @param srvId Server id.
+     * @param projectId Project id.
+     * @param chunk Chunk.
+     */
+    public void saveChunk(int srvId, String projectId, Set<MuteInfo> chunk) {
 
 Review comment:
   To make this method concurrent we should lock on updated entry. But please 
consider cache transformation instead.

----------------------------------------------------------------
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

Reply via email to