Skip to content

Commit

Permalink
mv vcr out
Browse files Browse the repository at this point in the history
  • Loading branch information
snalli committed Dec 6, 2023
1 parent 04030f0 commit 24dd75f
Show file tree
Hide file tree
Showing 11 changed files with 1,969 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public VcrMetrics getVcrMetrics() {
}

/** For testing only */
CloudStorageCompactor getCloudStorageCompactor() {
public CloudStorageCompactor getCloudStorageCompactor() {
return cloudStorageCompactor;
}

Expand Down
418 changes: 418 additions & 0 deletions ambry-vcr/src/main/java/com/github/ambry/vcr/AmbryCloudRequests.java

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions ambry-vcr/src/main/java/com/github/ambry/vcr/VcrMain.java
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 ambry-vcr/src/main/java/com/github/ambry/vcr/VcrRequests.java
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;
}
}
Loading

0 comments on commit 24dd75f

Please sign in to comment.