flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request #2388: [FLINK-4347][cluster management] Implement SlotMan...
Date Mon, 22 Aug 2016 15:03:03 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2388#discussion_r75694327
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/SlotManager.java
---
    @@ -0,0 +1,519 @@
    +/*
    + * 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.flink.runtime.clusterframework;
    +
    +import com.google.common.collect.BiMap;
    +import com.google.common.collect.HashBiMap;
    +import org.apache.flink.annotation.VisibleForTesting;
    +import org.apache.flink.runtime.clusterframework.types.AllocationID;
    +import org.apache.flink.runtime.clusterframework.types.ResourceID;
    +import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
    +import org.apache.flink.runtime.clusterframework.types.ResourceSlot;
    +import org.apache.flink.runtime.clusterframework.types.SlotID;
    +import org.apache.flink.runtime.rpc.resourcemanager.ResourceManagerGateway;
    +import org.apache.flink.runtime.rpc.resourcemanager.SlotRequest;
    +import org.apache.flink.runtime.rpc.taskexecutor.SlotReport;
    +import org.apache.flink.runtime.rpc.taskexecutor.SlotStatus;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.HashMap;
    +import java.util.LinkedHashMap;
    +import java.util.Map;
    +
    +import static org.apache.flink.util.Preconditions.checkNotNull;
    +
    +/**
    + * SlotManager is responsible for receiving slot requests and do slot allocations. It
allows to request
    + * slots from registered TaskManagers and issues container allocation requests in case
of there are not
    + * enough available slots. Besides, it should sync its slot allocation with TaskManager's
heartbeat.
    + * <p>
    + * The main operation principle of SlotManager is:
    + * <ul>
    + * <li>1. All slot allocation status should be synced with TaskManager, which is
the ground truth.</li>
    + * <li>2. All slots that have registered must be tracked, either by free pool or
allocated pool.</li>
    + * <li>3. All slot requests will be handled by best efforts, there is no guarantee
that one request will be
    + * fulfilled in time or correctly allocated. Conflicts or timeout or some special error
will happen, it should
    + * be handled outside SlotManager. SlotManager will make each decision based on the information
it currently
    + * holds.</li>
    + * </ul>
    + * <b>IMPORTANT:</b> This class is <b>Not Thread-safe</b>.
    + */
    +public abstract class SlotManager {
    +
    +	private static final Logger LOG = LoggerFactory.getLogger(SlotManager.class);
    +
    +	/** Gateway to communicate with ResourceManager */
    +	private final ResourceManagerGateway resourceManagerGateway;
    +
    +	/** All registered slots, including free and allocated slots */
    +	private final Map<ResourceID, Map<SlotID, ResourceSlot>> registeredSlots;
    +
    +	/** All pending slot requests, waiting available slots to fulfil */
    +	private final Map<AllocationID, SlotRequest> pendingSlotRequests;
    +
    +	/** All free slots that can be used to be allocated */
    +	private final Map<SlotID, ResourceSlot> freeSlots;
    +
    +	/** All allocations, we can lookup allocations either by SlotID or AllocationID */
    +	private final AllocationMap allocationMap;
    +
    +	public SlotManager(ResourceManagerGateway resourceManagerGateway) {
    +		this.resourceManagerGateway = resourceManagerGateway;
    --- End diff --
    
    `checkNotNull` would be good here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message