[
https://issues.apache.org/jira/browse/HDDS-1382?focusedWorklogId=229475&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-229475
]
ASF GitHub Bot logged work on HDDS-1382:
----------------------------------------
Author: ASF GitHub Bot
Created on: 17/Apr/19 22:46
Start Date: 17/Apr/19 22:46
Worklog Time Spent: 10m
Work Description: xiaoyuyao commented on pull request #693: HDDS-1382.
Create customized CSI server for Ozone.
URL: https://github.com/apache/hadoop/pull/693#discussion_r276461856
##########
File path:
hadoop-ozone/csi/src/main/java/org/apache/hadoop/ozone/csi/ControllerService.java
##########
@@ -0,0 +1,115 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hadoop.ozone.csi;
+
+import java.io.IOException;
+
+import org.apache.hadoop.ozone.client.OzoneClient;
+
+import csi.v1.ControllerGrpc.ControllerImplBase;
+import csi.v1.Csi.CapacityRange;
+import csi.v1.Csi.ControllerGetCapabilitiesRequest;
+import csi.v1.Csi.ControllerGetCapabilitiesResponse;
+import csi.v1.Csi.ControllerServiceCapability;
+import csi.v1.Csi.ControllerServiceCapability.RPC;
+import csi.v1.Csi.ControllerServiceCapability.RPC.Type;
+import csi.v1.Csi.CreateVolumeRequest;
+import csi.v1.Csi.CreateVolumeResponse;
+import csi.v1.Csi.DeleteVolumeRequest;
+import csi.v1.Csi.DeleteVolumeResponse;
+import csi.v1.Csi.Volume;
+import io.grpc.stub.StreamObserver;
+
+/**
+ * CSI controller service.
+ * <p>
+ * This service usually runs only once and responsible for the creation of
+ * the volume.
+ */
+public class ControllerService extends ControllerImplBase {
+
+ private OzoneClient ozoneClient;
+
+ public ControllerService(OzoneClient ozoneClient) {
+ this.ozoneClient = ozoneClient;
+ }
+
+ @Override
+ public void createVolume(CreateVolumeRequest request,
+ StreamObserver<CreateVolumeResponse> responseObserver) {
+ try {
+ ozoneClient.getObjectStore().createS3Bucket("hadoop", request.getName());
+
+ long size = findSize(request.getCapacityRange());
+
+ CreateVolumeResponse response = CreateVolumeResponse.newBuilder()
+ .setVolume(Volume.newBuilder()
+ .setVolumeId(request.getName())
+ .setCapacityBytes(size))
+ .build();
+
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ } catch (IOException e) {
+ responseObserver.onError(e);
+ }
+ }
+
+ private long findSize(CapacityRange capacityRange) {
+ if (capacityRange.getRequiredBytes() != 0) {
+ return capacityRange.getRequiredBytes();
+ } else {
+ if (capacityRange.getLimitBytes() != 0) {
+ return Math.min(1000_000_000, capacityRange.getLimitBytes());
Review comment:
Can we make 1000_000_000 configurable?
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 229475)
Time Spent: 0.5h (was: 20m)
> Create customized CSI server for Ozone
> --------------------------------------
>
> Key: HDDS-1382
> URL: https://issues.apache.org/jira/browse/HDDS-1382
> Project: Hadoop Distributed Data Store
> Issue Type: Sub-task
> Reporter: Elek, Marton
> Assignee: Elek, Marton
> Priority: Major
> Labels: pull-request-available
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> CSI (Container Storage Interface) is a vendor neutral storage interface
> specification for container orchestrators. CSI support is implemented in
> YARN, Kubernetes and Mesos. Implementing a CSI server makes it easy to mount
> disk volumes for containers.
> See https://github.com/container-storage-interface/spec for more details
> about the spec.
> Until now we used https://github.com/CTrox/csi-s3 server to support CSI
> specification. Using an ozone specific CSI server would have the following
> advantages:
> * We can provide additional functionalities (as we have access to the
> internal Ozone API not just the very generic s3 api).
> * Security setup can be synchronized.
> * Increased stability
> * Simplified deployment (only the minimal set of the components are required
> to be installed)
> The CSI specification itself is very simple
> (https://github.com/container-storage-interface/spec/blob/master/csi.proto)
> at least the part which is required for Ozone.
> We can use various fuse s3 driver to mount the ozone buckets via s3.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]