-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,969 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
418 changes: 418 additions & 0 deletions
418
ambry-vcr/src/main/java/com/github/ambry/vcr/AmbryCloudRequests.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright 2019 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package com.github.ambry.vcr; | ||
|
||
import com.github.ambry.clustermap.ClusterAgentsFactory; | ||
import com.github.ambry.commons.LoggingNotificationSystem; | ||
import com.github.ambry.config.ClusterMapConfig; | ||
import com.github.ambry.config.VerifiableProperties; | ||
import com.github.ambry.utils.InvocationOptions; | ||
import com.github.ambry.utils.Utils; | ||
import java.util.Properties; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* Start point for creating an instance of {@link VcrServer} and starting/shutting it down. | ||
*/ | ||
public class VcrMain { | ||
private static final Logger logger = LoggerFactory.getLogger(VcrMain.class); | ||
|
||
public static void main(String[] args) { | ||
final VcrServer vcrServer; | ||
int exitCode = 0; | ||
try { | ||
InvocationOptions options = new InvocationOptions(args); | ||
Properties properties = Utils.loadProps(options.serverPropsFilePath); | ||
VerifiableProperties verifiableProperties = new VerifiableProperties(properties); | ||
ClusterMapConfig clusterMapConfig = new ClusterMapConfig(verifiableProperties); | ||
ClusterAgentsFactory clusterAgentsFactory = | ||
Utils.getObj(clusterMapConfig.clusterMapClusterAgentsFactory, clusterMapConfig, | ||
options.hardwareLayoutFilePath, options.partitionLayoutFilePath); | ||
logger.info("Bootstrapping VcrServer"); | ||
vcrServer = new VcrServer(verifiableProperties, clusterAgentsFactory, new LoggingNotificationSystem(), null); | ||
// attach shutdown handler to catch control-c | ||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
public void run() { | ||
logger.info("Received shutdown signal. Shutting down VcrServer"); | ||
vcrServer.shutdown(); | ||
} | ||
}); | ||
vcrServer.startup(); | ||
vcrServer.awaitShutdown(Integer.MAX_VALUE); | ||
} catch (Exception e) { | ||
logger.error("Exception during bootstrap of VcrServer", e); | ||
exitCode = 1; | ||
} | ||
logger.info("Exiting VcrMain"); | ||
System.exit(exitCode); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
ambry-vcr/src/main/java/com/github/ambry/vcr/VcrRequests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* Copyright 2019 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package com.github.ambry.vcr; | ||
|
||
import com.codahale.metrics.MetricRegistry; | ||
import com.github.ambry.clustermap.ClusterMap; | ||
import com.github.ambry.clustermap.DataNodeId; | ||
import com.github.ambry.clustermap.PartitionId; | ||
import com.github.ambry.commons.ServerMetrics; | ||
import com.github.ambry.network.NetworkRequest; | ||
import com.github.ambry.network.RequestResponseChannel; | ||
import com.github.ambry.notification.NotificationSystem; | ||
import com.github.ambry.protocol.RequestOrResponseType; | ||
import com.github.ambry.replication.FindTokenHelper; | ||
import com.github.ambry.replication.ReplicationEngine; | ||
import com.github.ambry.server.AmbryRequests; | ||
import com.github.ambry.server.ServerErrorCode; | ||
import com.github.ambry.server.StoreManager; | ||
import com.github.ambry.store.Store; | ||
import com.github.ambry.store.StoreKeyConverterFactory; | ||
import com.github.ambry.store.StoreKeyFactory; | ||
import java.io.IOException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* Request implementation class for Vcr. All requests to the vcr server are | ||
* handled by this class. | ||
*/ | ||
public class VcrRequests extends AmbryRequests { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(VcrRequests.class); | ||
|
||
public VcrRequests(StoreManager storeManager, RequestResponseChannel requestResponseChannel, ClusterMap clusterMap, | ||
DataNodeId currentNode, MetricRegistry registry, ServerMetrics serverMetrics, FindTokenHelper findTokenHelper, | ||
NotificationSystem notification, ReplicationEngine replicationEngine, StoreKeyFactory storageKeyFactory, | ||
StoreKeyConverterFactory storeKeyConverterFactory) { | ||
super(storeManager, requestResponseChannel, clusterMap, currentNode, registry, serverMetrics, findTokenHelper, | ||
notification, replicationEngine, storageKeyFactory, storeKeyConverterFactory); | ||
} | ||
|
||
@Override | ||
public void handlePutRequest(NetworkRequest request) throws IOException, InterruptedException { | ||
throw new UnsupportedOperationException("Request type not supported"); | ||
} | ||
|
||
@Override | ||
public void handleDeleteRequest(NetworkRequest request) throws IOException, InterruptedException { | ||
throw new UnsupportedOperationException("Request type not supported"); | ||
} | ||
|
||
@Override | ||
public void handlePurgeRequest(NetworkRequest request) throws IOException, InterruptedException { | ||
throw new UnsupportedOperationException("Request type not supported"); | ||
} | ||
|
||
@Override | ||
public void handleTtlUpdateRequest(NetworkRequest request) throws IOException, InterruptedException { | ||
throw new UnsupportedOperationException("Request type not supported"); | ||
} | ||
|
||
@Override | ||
public void handleReplicateBlobRequest(NetworkRequest request) throws IOException, InterruptedException { | ||
throw new UnsupportedOperationException("Request type not supported"); | ||
} | ||
|
||
@Override | ||
protected ServerErrorCode validateRequest(PartitionId partition, RequestOrResponseType requestType, | ||
boolean skipPartitionAvailableCheck) { | ||
// 1. Check partition is null | ||
if (partition == null) { | ||
metrics.badRequestError.inc(); | ||
return ServerErrorCode.Bad_Request; | ||
} | ||
return ServerErrorCode.No_Error; | ||
} | ||
|
||
@Override | ||
protected long getRemoteReplicaLag(Store store, long totalBytesRead) { | ||
return -1; | ||
} | ||
} |
Oops, something went wrong.