Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run azure recovery locally #1230

Merged
merged 7 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions ambry-cloud/src/main/java/com.github.ambry.cloud/VcrMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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.cloud;

import com.github.ambry.clustermap.ClusterAgentsFactory;
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 {
lightningrob marked this conversation as resolved.
Show resolved Hide resolved
private static 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, 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);
}
}
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,24 @@ task allJar(type: Jar, dependsOn: subprojects.assemble) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

task allJarVcr(type: Jar, dependsOn: subprojects.assemble) {
manifest {
attributes 'Implementation-Title': 'Ambry',
'Main-Class': 'com.github.ambry.cloud.VcrMain'
}
zip64 true
destinationDir = file('target')
baseName = 'ambry-vcr'
subprojects.each { subproject ->
from {
(subproject.configurations.archives.allArtifacts.files + subproject.configurations.runtime).collect {
zipTree(it)
}
}
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

task codeCoverageReport(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

Expand Down
24 changes: 24 additions & 0 deletions config/azureconfig/HardwareLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"clusterName": "OneDiskOneReplica",
"version": 99,
"datacenters": [
{
"dataNodes": [
{
"disks": [
{
"capacityInBytes": 21474836480,
"hardwareState": "AVAILABLE",
"mountPath": "/tmp"
}
],
"hardwareState": "AVAILABLE",
"hostname": "localhost",
"port": 6673
}
],
"name": "Datacenter",
"id" : "1"
}
]
}
19 changes: 19 additions & 0 deletions config/azureconfig/PartitionLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"clusterName": "OneDiskOneReplica",
"version": 88,
"partitions": [
{
"id": 0,
"partitionClass": "max-replicas-all-datacenters",
"partitionState": "READ_WRITE",
"replicaCapacityInBytes": 10737418240,
"replicas": [
{
"hostname": "localhost",
"mountPath": "/tmp",
"port": 6673
}
]
}
]
}
19 changes: 19 additions & 0 deletions config/azureconfig/server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# 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.
#

host.name=localhost
port=6673

# cluster map
clustermap.cluster.name=AmbryDev
clustermap.datacenter.name=Datacenter
clustermap.host.name=localhost
26 changes: 26 additions & 0 deletions config/azureconfig/vcr.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# 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.
#

host.name=localhost
port=6672

# cluster map
clustermap.cluster.name=AmbryDev
clustermap.datacenter.name=Datacenter
clustermap.host.name=localhost
clustermap.port=6673
azure.storage.connection.string=<CONNECTION STRING FOR AZURE BLOB STORAGE>
cosmos.endpoint=<COSMOS ENDPOINT>
cosmos.key=<COSMOS KEY>
vcr.assigned.partitions=0
cosmos.collection.link=<PATH OF COSMOS COLLECTION>
kms.default.container.key=<KMS CONTAINER KEY>