Github user kevdoran commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi/pull/120#discussion_r177827045
  
    --- Diff: 
minifi-c2/minifi-c2-framework/src/main/java/org/apache/nifi/minifi/c2/core/service/StandardC2Service.java
 ---
    @@ -0,0 +1,494 @@
    +/*
    + * 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.nifi.minifi.c2.core.service;
    +
    +import 
org.apache.nifi.minifi.c2.api.provider.agent.AgentPersistenceProvider;
    +import 
org.apache.nifi.minifi.c2.api.provider.device.DevicePersistenceProvider;
    +import 
org.apache.nifi.minifi.c2.api.provider.operations.OperationPersistenceProvider;
    +import org.apache.nifi.minifi.c2.core.exception.ResourceNotFoundException;
    +import org.apache.nifi.minifi.c2.model.Agent;
    +import org.apache.nifi.minifi.c2.model.AgentClass;
    +import org.apache.nifi.minifi.c2.model.AgentManifest;
    +import org.apache.nifi.minifi.c2.model.Device;
    +import org.apache.nifi.minifi.c2.model.OperationRequest;
    +import org.apache.nifi.minifi.c2.model.OperationState;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import javax.validation.ConstraintViolation;
    +import javax.validation.ConstraintViolationException;
    +import javax.validation.Validator;
    +import java.util.List;
    +import java.util.Optional;
    +import java.util.Set;
    +import java.util.UUID;
    +import java.util.concurrent.locks.Lock;
    +import java.util.concurrent.locks.ReentrantReadWriteLock;
    +
    +@Service
    +public class StandardC2Service implements C2Service {
    +
    +    private static final Logger logger = 
LoggerFactory.getLogger(StandardC2Service.class);
    +
    +    private final AgentPersistenceProvider agentPersistenceProvider;
    +    private final DevicePersistenceProvider devicePersistenceProvider;
    +    private final OperationPersistenceProvider 
operationPersistenceProvider;
    +    private final Validator validator;
    +
    +    private final ReentrantReadWriteLock lock = new 
ReentrantReadWriteLock();
    --- End diff --
    
    Great points, @bbende. Thanks for the input.
    
    This is probably too limiting as you point. One of the things I like about 
trying to handle concurrency in the service layer, as we did for registry, is 
that there is less burden placed on the implementations of the persistence 
providers that are called from the service methods (though if they are DB 
backed most DB engines will take care of that for you). But I agree, as 
implemented here, it's too much of a performance trade off if we want to 
support high concurrency / number of clients for a C2 server instance.
    
    I'll take another pass at this and look at it on more of a case-by-case 
basis.


---

Reply via email to