imbajin commented on code in PR #3331: URL: https://github.com/apache/hugegraph/pull/3331#discussion_r4261651219
########## hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/LoadingMode.java: ########## @@ -0,0 +1,113 @@ +/* + * 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.hugegraph; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +import org.apache.hugegraph.type.define.GraphMode; +import org.apache.hugegraph.util.E; + +import com.google.common.collect.ImmutableMap; + +/** Same graph-instance ownership; this state is neither persisted nor distributed. */ +public final class LoadingMode { + + private static final int MAX_RELEASED = 1024; + + private final String instance = UUID.randomUUID().toString(); + private final Map<String, String> active = new HashMap<>(); + private final Map<String, String> released = new HashMap<>(); + private long epoch; + private volatile GraphMode mode = GraphMode.NONE; + + public GraphMode mode() { + return this.mode; + } + + public synchronized void mode(GraphMode mode) { + Objects.requireNonNull(mode, "mode"); + E.checkState(this.active.isEmpty(), "Loading owners are active; release them before setting graph mode"); Review Comment: Recorded for correction before the paired protocol merges: expected owner conflicts should return a client error, and the mode-change log should follow a successful setter. The current head has not changed to implement this request. Keeping this thread open alongside the blocking recovery discussion. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
