Skip to content

Commit

Permalink
Merge pull request #26 from aiven/dmitry-potepalov-cassandra-deploy-417
Browse files Browse the repository at this point in the history
Rebase our patches on top of cassandra-4.1.7
  • Loading branch information
aris-aiven authored Nov 12, 2024
2 parents ca49452 + 59987dc commit 516b245
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 3 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.
#
#
name: Build cassandra

# Default to read-only access to all APIs.
permissions: read-all

on:
push: {}
pull_request: {}

jobs:
test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- name: checkout-code
uses: actions/checkout@v3
- name: setup jdk 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
- name: test
continue-on-error: true
run: |
ant test
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: "build/test/output/*.xml"
3 changes: 3 additions & 0 deletions src/java/org/apache/cassandra/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public static Set<String> splitCommaDelimited(String src)
/** Triggers automatic allocation of tokens if set, based on the provided replica count for a datacenter */
public Integer allocate_tokens_for_local_replication_factor = null;

public boolean skip_bootstrap_streaming = false;
public String replace_address_first_boot = null;

@Replaces(oldName = "native_transport_idle_timeout_in_ms", converter = Converters.MILLIS_DURATION_LONG, deprecated = true)
public DurationSpec.LongMillisecondsBound native_transport_idle_timeout = new DurationSpec.LongMillisecondsBound("0ms");

Expand Down
12 changes: 12 additions & 0 deletions src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,8 @@ public static InetAddressAndPort getReplaceAddress()
return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address", null));
else if (System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null) != null)
return InetAddressAndPort.getByName(System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot", null));
else if (conf.replace_address_first_boot != null)
return InetAddressAndPort.getByName(conf.replace_address_first_boot);
return null;
}
catch (UnknownHostException e)
Expand All @@ -1749,6 +1751,16 @@ else if (System.getProperty(Config.PROPERTY_PREFIX + "replace_address_first_boot
}
}

public static boolean skipBootstrapStreaming()
{
return conf.skip_bootstrap_streaming;
}

public static boolean replaceOnFirstBootRequested()
{
return System.getProperty("cassandra.replace_address_first_boot", null) != null || conf.replace_address_first_boot != null;
}

public static Collection<String> getReplaceTokens()
{
return tokensFromString(System.getProperty(Config.PROPERTY_PREFIX + "replace_token", null));
Expand Down
9 changes: 8 additions & 1 deletion src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ public boolean isReplacing()
if (replacing)
return true;

if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemKeyspace.bootstrapComplete())
if (DatabaseDescriptor.replaceOnFirstBootRequested() && SystemKeyspace.bootstrapComplete())
{
logger.info("Replace address on first boot requested; this node is already bootstrapped");
return false;
Expand Down Expand Up @@ -2060,6 +2060,13 @@ public boolean bootstrap(final Collection<Token> tokens, long bootstrapTimeoutMi
invalidateLocalRanges();
repairPaxosForTopologyChange("bootstrap");

if (DatabaseDescriptor.skipBootstrapStreaming())
{
bootstrapFinished();
logger.info("Bootstrap skipped for tokens {}", tokens);
return true;
}

Future<StreamState> bootstrapStream = startBootstrap(tokens);
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ else if (compression.equals("lz4"))
clientState.setDriverVersion(options.get(DRIVER_VERSION));
}

if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
if (DatabaseDescriptor.getAuthenticator().requireAuthentication()) {
String authenticatorClassName = DatabaseDescriptor.getAuthenticator().getClass().getName();
if (authenticatorClassName.equals("io.aiven.cassandra.auth.AivenAuthenticator"))
authenticatorClassName = "org.apache.cassandra.auth.PasswordAuthenticator";
return new AuthenticateMessage(authenticatorClassName);
}
else
return new ReadyMessage();
}
Expand Down

0 comments on commit 516b245

Please sign in to comment.