[
https://issues.apache.org/jira/browse/MINIFI-448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16417407#comment-16417407
]
ASF GitHub Bot commented on MINIFI-448:
---------------------------------------
Github user bbende commented on a diff in the pull request:
https://github.com/apache/nifi-minifi/pull/120#discussion_r177765399
--- 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 --
Do we think the read/write lock approach is too limiting for C2?
I know we did this in registry to ensure consistency when interacting with
more than one data store, but the trade-off is that it reduces the concurrency
a lot because all threads are blocked while one thread has the write lock.
I don't know the level of concurrent requests we are anticipating here so
it may be a non-issue, but just wanted to throw it out there. This also may be
totally fine for initial implementation, and we can modify/improve later.
I also haven't read through all the methods below yet, but if there isn't a
case where a single method performs operations across multiple persistence
providers, then we could probably make the locks more granular and have a lock
for each persistence provider so that agent calls are not blocked by device
calls, etc.
> Define service layer interfaces for MiNIFi C2 Server
> ----------------------------------------------------
>
> Key: MINIFI-448
> URL: https://issues.apache.org/jira/browse/MINIFI-448
> Project: Apache NiFi MiNiFi
> Issue Type: New Feature
> Components: Command and Control
> Reporter: Kevin Doran
> Assignee: Kevin Doran
> Priority: Major
>
> Define service layer interfaces that will back the external interfaces for
> the MiNiFi C2 server
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)