Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
feee1b7
Added the workflow
RahulSingh1895 Dec 28, 2022
93d9213
with skip krat
RahulSingh1895 Dec 28, 2022
db1a2b5
Adde the change to local fork
RahulSingh1895 Dec 28, 2022
0bd6a85
Fixed the job name fix
RahulSingh1895 Dec 28, 2022
1f260c0
Added upload arti-jar
RahulSingh1895 Dec 28, 2022
d01599a
jar build
RahulSingh1895 Dec 28, 2022
dab6927
release in workflow
RahulSingh1895 Dec 28, 2022
1163298
release in workflow
RahulSingh1895 Dec 28, 2022
a2430d4
updated release name
RahulSingh1895 Dec 28, 2022
a40664a
Added the new version
RahulSingh1895 Dec 28, 2022
1b0e5d8
updated allocate
RahulSingh1895 Jan 5, 2023
21de927
updated database descriptor
RahulSingh1895 Jan 5, 2023
141e638
Added the reasociation flag false
RahulSingh1895 Jan 6, 2023
bb91cf6
Added artifact
RahulSingh1895 Jan 6, 2023
706f861
Addeed zip in workflow
RahulSingh1895 Jan 6, 2023
41549a5
Addeed zip in workflow
RahulSingh1895 Jan 6, 2023
7936632
Addeed zip in workflow
RahulSingh1895 Jan 6, 2023
873634d
Compress test
RahulSingh1895 Jan 6, 2023
8cfdaed
Compress test 2
RahulSingh1895 Jan 6, 2023
c165c1e
Compress test 2
RahulSingh1895 Jan 6, 2023
e51952c
with jar test
RahulSingh1895 Jan 6, 2023
5872ac0
with jar test
RahulSingh1895 Jan 6, 2023
88ccf98
with jar test 2
RahulSingh1895 Jan 6, 2023
db3aa5d
with jar test 3
RahulSingh1895 Jan 6, 2023
bd406ff
Added the tag name
RahulSingh1895 Jan 6, 2023
5d13d07
version
RahulSingh1895 Jan 6, 2023
8f14529
push test
RahulSingh1895 Jan 6, 2023
b7c1184
Specific packages
RahulSingh1895 Jan 9, 2023
4a22901
new release
RahulSingh1895 Jan 9, 2023
469ef51
Added the commit id
RahulSingh1895 Jan 9, 2023
1d3bef1
Added the spaces
RahulSingh1895 Jan 9, 2023
f51d086
Added git
RahulSingh1895 Jan 9, 2023
e3d5a80
Added git
RahulSingh1895 Jan 9, 2023
8cfdf21
Added git sha
RahulSingh1895 Jan 9, 2023
a35821f
Added git sha
RahulSingh1895 Jan 9, 2023
60ed09c
short sha
RahulSingh1895 Jan 9, 2023
9ac81ba
Added the workflow changes'
RahulSingh1895 Jan 9, 2023
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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Cassandra Deployment
on:
push:
branches:
- master
- main
- juspay-4.3
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 7
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Ant
run: ant -noinput -buildfile build.xml jar -Duse.jdk11=true -Drat.skip=true
- name: Copy files
run: |
mkdir -p apache-cassandra
cp -R bin apache-cassandra
cp -R build/tools apache-cassandra
cp -R pylib apache-cassandra
cp -R conf apache-cassandra
cp -R doc apache-cassandra
cp -R lib apache-cassandra
cp -R build/apache-cassandra-4.1.1-SNAPSHOT.jar apache-cassandra/lib
- name: Compress
uses: a7ul/[email protected]
id: compress
with:
command: c
cwd: apache-cassandra
files: ./
outPath: apache-cassandra-release-${{steps.short-sha.outputs.sha}}.tar.gz
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: Release apache-cassandra-${{ steps.short-sha.outputs.sha }}
tag_name: apache-cassandra-${{ steps.short-sha.outputs.sha }}
body_path: CONTRIBUTING.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./apache-cassandra-release-${{ steps.short-sha.outputs.sha }}.tar.gz
asset_name: apache-cassandra-release-${{ steps.short-sha.outputs.sha }}.tar.gz
asset_content_type: application/gzip
6 changes: 5 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@
<exclusion groupId="org.checkerframework" artifactId="checker-qual" />
<exclusion groupId="com.google.errorprone" artifactId="error_prone_annotations" />
</dependency>
<dependency groupId="software.amazon.awssdk" artifactId="ec2" version="2.19.9" />
<dependency groupId="software.amazon.awssdk" artifactId="apache-client" version="2.19.9" />
<dependency groupId="com.google.jimfs" artifactId="jimfs" version="1.1"/>
<dependency groupId="org.hdrhistogram" artifactId="HdrHistogram" version="2.1.9"/>
<dependency groupId="commons-cli" artifactId="commons-cli" version="1.1"/>
Expand Down Expand Up @@ -786,6 +788,8 @@
<scm connection="${scm.connection}" developerConnection="${scm.developerConnection}" url="${scm.url}"/>
<dependency groupId="org.xerial.snappy" artifactId="snappy-java"/>
<dependency groupId="org.lz4" artifactId="lz4-java"/>
<dependency groupId="software.amazon.awssdk" artifactId="ec2" />
<dependency groupId="software.amazon.awssdk" artifactId="apache-client" />
<dependency groupId="com.ning" artifactId="compress-lzf"/>
<dependency groupId="com.google.guava" artifactId="guava"/>
<dependency groupId="commons-cli" artifactId="commons-cli"/>
Expand Down Expand Up @@ -2365,4 +2369,4 @@
<import file="${basedir}/.build/build-resolver.xml"/>
<import file="${basedir}/.build/build-rat.xml"/>
<import file="${basedir}/.build/build-owasp.xml"/>
</project>
</project>
6 changes: 2 additions & 4 deletions conf/cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,9 @@ seed_provider:
# Cassandra nodes use this list of hosts to find each other and learn
# the topology of the ring. You must change this if you are running
# multiple nodes!
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
- class_name: org.apache.cassandra.locator.HttpSeedProvider
parameters:
# seeds is actually a comma-delimited list of addresses.
# Ex: "<ip1>,<ip2>,<ip3>"
- seeds: "127.0.0.1:7000"
- seedsUrl: "https://5wv7m0j42b.execute-api.ap-northeast-1.amazonaws.com/default/getSeedsFromMem"

# For workloads with more data than can fit in memory, Cassandra's
# bottleneck will be reads that need to fetch data from
Expand Down
79 changes: 79 additions & 0 deletions src/java/org/apache/cassandra/config/AllocateAddress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.apache.cassandra.config;

import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.AllocateAddressRequest;
import software.amazon.awssdk.services.ec2.model.DomainType;
import software.amazon.awssdk.services.ec2.model.AllocateAddressResponse;
import software.amazon.awssdk.services.ec2.model.AssociateAddressRequest;
import software.amazon.awssdk.services.ec2.model.AssociateAddressResponse;
import software.amazon.awssdk.services.ec2.model.Ec2Exception;
import software.amazon.awssdk.services.ec2.model.DescribeAddressesResponse;
import software.amazon.awssdk.services.ec2.model.DescribeAddressesRequest;
import software.amazon.awssdk.services.ec2.model.Filter;
import software.amazon.awssdk.services.ec2.model.Address;
import java.util.Arrays;
import java.util.Collection;
import software.amazon.awssdk.regions.internal.util.EC2MetadataUtils;

// import software.amazon.awssdk.http.ApacheHttpClient;
// import com.amazonaws.util.EC2MetadataUtils;
// import com.amazonaws.services.ec2.model.Address;
// import com.amazonaws.services.ec2.model.DescribeAddressesResult;

public class AllocateAddress {
public static String allocateAddress() {
try {
String instanceId = EC2MetadataUtils.getInstanceId(); // "i-0a17b1a5f2662ecac";
Region region = Region.AP_NORTHEAST_1;
Ec2Client ec2 = Ec2Client.builder()
.region(region)
// .credentialsProvider(ProfileCredentialsProvider.create())
.build();
Collection<String> filterValues = Arrays.asList("cassandra");
Filter filter = Filter.builder().name("tag:cluster").values(filterValues).build();
Collection<Filter> filters = Arrays.asList(filter);
DescribeAddressesRequest addressRequest = DescribeAddressesRequest.builder().filters(filters).build();
DescribeAddressesResponse response = ec2.describeAddresses();


for(Address address : response.addresses()) {
if (address.instanceId() == null){
AssociateAddressRequest associateRequest = AssociateAddressRequest.builder()
.allowReassociation(false)
.instanceId(instanceId)
.allocationId(address.allocationId())
.build();
try {
AssociateAddressResponse associateResponse = ec2.associateAddress(associateRequest);
break;
}
catch (Ec2Exception e) {
continue;
}
}
}

// AllocateAddressRequest allocateRequest = AllocateAddressRequest.builder()
// .domain(DomainType.VPC)
// .build();

// AllocateAddressResponse allocateResponse = ec2.allocateAddress(allocateRequest);
// String allocationId = allocateResponse.allocationId();
// AssociateAddressRequest associateRequest = AssociateAddressRequest.builder()
// .instanceId(instanceId)
// .allocationId(allocationId)
// .build();

// AssociateAddressResponse associateResponse = ec2.associateAddress(associateRequest);
ec2.close();

return "";

} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
}
return "";
}
}
33 changes: 11 additions & 22 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import org.apache.cassandra.service.CacheService.CacheType;
import org.apache.cassandra.service.paxos.Paxos;
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.config.AllocateAddress;

import static org.apache.cassandra.config.CassandraRelevantProperties.OS_ARCH;
import static org.apache.cassandra.config.CassandraRelevantProperties.SUN_ARCH_DATA_MODEL;
Expand Down Expand Up @@ -202,6 +203,9 @@ public static void daemonInitialization(Supplier<Config> config) throws Configur

setConfig(config.get());
applyAll();
System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$");
AllocateAddress.allocateAddress();
System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$");
AuthConfig.applyAuth();
}

Expand Down Expand Up @@ -1039,35 +1043,20 @@ public static void applyAddressConfig() throws ConfigurationException

public static void applyAddressConfig(Config config) throws ConfigurationException
{
listenAddress = null;
// listenAddress = null;
rpcAddress = null;
broadcastAddress = null;
broadcastRpcAddress = null;

/* Local IP, hostname or interface to bind services to */
if (config.listen_address != null && config.listen_interface != null)
try
{
throw new ConfigurationException("Set listen_address OR listen_interface, not both", false);
listenAddress = InetAddress.getLocalHost();
rpcAddress = listenAddress;
}
else if (config.listen_address != null)
{
try
{
listenAddress = InetAddress.getByName(config.listen_address);
}
catch (UnknownHostException e)
{
throw new ConfigurationException("Unknown listen_address '" + config.listen_address + '\'', false);
}

if (listenAddress.isAnyLocalAddress())
throw new ConfigurationException("listen_address cannot be a wildcard address (" + config.listen_address + ")!", false);
}
else if (config.listen_interface != null)
catch (UnknownHostException e)
{
listenAddress = getNetworkInterfaceAddress(config.listen_interface, "listen_interface", config.listen_interface_prefer_ipv6);
throw new ConfigurationException("Unknown broadcast_address '" + config.broadcast_address + '\'', false);
}

/* Gossip Address to broadcast */
if (config.broadcast_address != null)
{
Expand Down
128 changes: 128 additions & 0 deletions src/java/org/apache/cassandra/locator/HttpSeedProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package org.apache.cassandra.locator;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.net.http.HttpClient;
import java.net.http.HttpResponse.BodyHandlers;
import java.net.http.HttpRequest;
import java.util.function.Supplier;
import java.net.URI;
import org.apache.cassandra.config.Config;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonProperty;

// class JsonBodyHandler<W> implements HttpResponse.BodyHandler<Supplier<W>> {

// private final Class<W> wClass;

// public JsonBodyHandler(Class<W> wClass) {
// this.wClass = wClass;
// }

// public static <W> HttpResponse.BodySubscriber<Supplier<W>> asJSON(Class<W> targetType) {
// HttpResponse.BodySubscriber<InputStream> upstream = HttpResponse.BodySubscribers.ofInputStream();

// return HttpResponse.BodySubscribers.mapping(
// upstream,
// inputStream -> toSupplierOfType(inputStream, targetType));
// }

// public static <W> Supplier<W> toSupplierOfType(InputStream inputStream, Class<W> targetType) {
// return () -> {
// try (InputStream stream = inputStream) {
// ObjectMapper objectMapper = new ObjectMapper();
// return objectMapper.readValue(stream, targetType);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// };
// }


// @Override
// public HttpResponse.BodySubscriber<Supplier<W>> apply(HttpResponse.ResponseInfo responseInfo) {
// return asJSON(wClass);
// }

// }


// class APOD {
// public final String copyright;
// public final String date;
// public final String explanation;
// public final String hdUrl;
// public final String mediaType;
// public final String serviceVersion;
// public final String title;
// public final String url;

// public APOD(@JsonProperty("copyright") String copyright,
// @JsonProperty("date") String date,
// @JsonProperty("explanation") String explanation,
// @JsonProperty("hdurl") String hdUrl,
// @JsonProperty("media_type") String mediaType,
// @JsonProperty("service_version") String serviceVersion,
// @JsonProperty("title") String title,
// @JsonProperty("url") String url) {
// this.copyright = copyright;
// this.date = date;
// this.explanation = explanation;
// this.hdUrl = hdUrl;
// this.mediaType = mediaType;
// this.serviceVersion = serviceVersion;
// this.title = title;
// this.url = url;
// }
// }

public class HttpSeedProvider implements SeedProvider
{
private static final Logger logger = LoggerFactory.getLogger(HttpSeedProvider.class);
public HttpClient client = HttpClient.newHttpClient();

public HttpSeedProvider(Map<String, String> args) {}

public List<InetAddressAndPort> getSeeds()
{
Config conf;
List<InetAddressAndPort> seeds = new ArrayList<>(0);
try
{
conf = DatabaseDescriptor.loadConfig();
var request = HttpRequest.newBuilder(
URI.create(conf.seed_provider.parameters.get("seedsUrl")))
.header("accept", "application/json")
.build();
var response = client.send(request, BodyHandlers.ofString());
System.out.println(response.body());

String[] hosts = response.body().replace("\"", "").split(",", -1);
seeds = new ArrayList<>(hosts.length);
for (String host : hosts)
{
String hostPortString = host.trim();
try
{
if(!hostPortString.isEmpty()) {
seeds.add(InetAddressAndPort.getByName(hostPortString));
}
}
catch (UnknownHostException ex)
{
logger.warn("Seed provider couldn't lookup host {}", host);
}
}
}
catch (Exception e)
{
throw new AssertionError(e);
}
return Collections.unmodifiableList(seeds);
}
}
6 changes: 3 additions & 3 deletions test/conf/cassandra-murmur.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ data_file_directories:
- build/test/cassandra/data
disk_access_mode: mmap
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "127.0.0.1:7012"
- class_name: org.apache.cassandra.locator.HttpSeedProvider
parameters:
- seedsUrl: "https://5wv7m0j42b.execute-api.ap-northeast-1.amazonaws.com/default/getSeedsFromMem"
endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
dynamic_snitch: true
server_encryption_options:
Expand Down
6 changes: 3 additions & 3 deletions test/conf/cassandra-old.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ data_file_directories:
- build/test/cassandra/data
disk_access_mode: mmap
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "127.0.0.1:7012"
- class_name: org.apache.cassandra.locator.HttpSeedProvider
parameters:
- seedsUrl: "https://5wv7m0j42b.execute-api.ap-northeast-1.amazonaws.com/default/getSeedsFromMem"
endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
dynamic_snitch: true
server_encryption_options:
Expand Down
Loading