alex-plekhanov commented on a change in pull request #6554: IGNITE-11073: Backup page store manager, initial URL: https://github.com/apache/ignite/pull/6554#discussion_r387732736
########## File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFileSender.java ########## @@ -0,0 +1,236 @@ +/* + * 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.internal.processors.cache.persistence.snapshot; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteLogger; +import org.apache.ignite.binary.BinaryType; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; +import org.apache.ignite.internal.processors.marshaller.MappedName; +import org.jetbrains.annotations.Nullable; + +/** + * + */ +abstract class SnapshotFileSender { + /** Busy processing lock. */ + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + /** Executor to run operation at. */ + private final Executor exec; + + /** {@code true} if sender is currently working */ + private volatile boolean closed; + + /** Ignite logger to use. */ + protected final IgniteLogger log; + + /** + * @param log Ignite logger to use. + */ + protected SnapshotFileSender(IgniteLogger log, Executor exec) { + this.exec = exec; + this.log = log.getLogger(SnapshotFileSender.class); + } + + /** + * @return Executor to run internal operations on. + */ + public Executor executor() { + return exec; + } + + /** + * @param mappings Local node marshaller mappings. + */ + public final void sendMarshallerMeta(List<Map<Integer, MappedName>> mappings) { + if (!lock.readLock().tryLock()) + return; + + try { + if (closed) + return; + + if (mappings == null) + return; + + sendMarshallerMeta0(mappings); + } + finally { + lock.readLock().unlock(); + } + } + + /** + * @param types Collection of known binary types. + */ + public final void sendBinaryMeta(Map<Integer, BinaryType> types) { Review comment: Use `Collection<BinaryType>` here instead of `Map` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
