mcvsubbu commented on a change in pull request #5277: URL: https://github.com/apache/incubator-pinot/pull/5277#discussion_r411585980
########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/SegmentUploader.java ########## @@ -0,0 +1,26 @@ +/** + * 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.pinot.core.data.manager.realtime; + +import java.io.File; + + +public interface SegmentUploader { + SegmentUploadStatus segmentUpload(File segmentFile); Review comment: ```suggestion SegmentUploadStatus uploadSegment(File segmentFile); ``` ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/SegmentUploadStatus.java ########## @@ -0,0 +1,47 @@ +/** + * 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.pinot.core.data.manager.realtime; + +public class SegmentUploadStatus { + // True if and only if the upload is successful. + private boolean uploadSuccessful; Review comment: ```suggestion private boolean _uploadSuccessful; ``` ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/SegmentUploader.java ########## @@ -0,0 +1,26 @@ +/** + * 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.pinot.core.data.manager.realtime; + +import java.io.File; + + +public interface SegmentUploader { + SegmentUploadStatus segmentUpload(File segmentFile); Review comment: why not just return the URL here? ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/SegmentUploadStatus.java ########## @@ -0,0 +1,47 @@ +/** + * 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.pinot.core.data.manager.realtime; + +public class SegmentUploadStatus { + // True if and only if the upload is successful. + private boolean uploadSuccessful; + // Segment location uri string when the upload is successful. + private String segmentLocation; Review comment: ```suggestion private String _segmentLocation; ``` ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/ControllerVipBasedSegmentUploader.java ########## @@ -0,0 +1,54 @@ +/** + * 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.pinot.core.data.manager.realtime; + +import java.io.File; +import org.apache.pinot.common.protocols.SegmentCompletionProtocol; +import org.apache.pinot.server.realtime.ServerSegmentCompletionProtocolHandler; +import org.slf4j.Logger; + + +// A segment uploader which uploads segments to the controller via the controller's segmentCommitUpload end point +// point. +public class ControllerVipBasedSegmentUploader implements SegmentUploader { + private final SegmentCompletionProtocol.Request.Params _params; + private final ServerSegmentCompletionProtocolHandler _protocolHandler; + private final Logger _segmentLogger; + private final String _controllerVipUrl; + + public ControllerVipBasedSegmentUploader(Logger segmentLogger, ServerSegmentCompletionProtocolHandler protocolHandler, + SegmentCompletionProtocol.Request.Params params, String controllerVipUrl) { + _segmentLogger = segmentLogger; + _protocolHandler = protocolHandler; + _params = params; + _controllerVipUrl = controllerVipUrl; + } + + @Override + public SegmentUploadStatus segmentUpload(File segmentFile) { + SegmentCompletionProtocol.Response segmentCommitUploadResponse = + _protocolHandler.segmentCommitUpload(_params, segmentFile, _controllerVipUrl); Review comment: you should not be using the protocol handler here. Instead, you need to introduce a method to upload the segment to contrller vip. Copy/paste protocolHandler.uploadSegment. Refactor the protocol handler to use this method. ########## File path: pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/SegmentUploadStatus.java ########## @@ -0,0 +1,47 @@ +/** + * 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.pinot.core.data.manager.realtime; + +public class SegmentUploadStatus { Review comment: You dont need this class. If return values turn out to be more complex, we can introduce a status class then ---------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
