diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml
index a525ffb7f1add..c6a28f178d2bf 100644
--- a/buildSrc/src/main/resources/checkstyle_suppressions.xml
+++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml
@@ -27,11 +27,15 @@
+
+
+
+
-
+
using azure host type " + hostType);
final Settings settings = Settings.builder()
diff --git a/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeService.java b/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeService.java
index 7c71ef9ff3321..a979db38ab334 100644
--- a/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeService.java
+++ b/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeService.java
@@ -47,44 +47,78 @@
public interface AzureComputeService {
final class Management {
- public static final Setting SUBSCRIPTION_ID_SETTING =
- Setting.simpleString("cloud.azure.management.subscription.id", Property.NodeScope, Property.Filtered);
- public static final Setting SERVICE_NAME_SETTING =
- Setting.simpleString("cloud.azure.management.cloud.service.name", Property.NodeScope);
+ public static final Setting SUBSCRIPTION_ID_SETTING = Setting.simpleString(
+ "cloud.azure.management.subscription.id",
+ Property.NodeScope,
+ Property.Filtered
+ );
+ public static final Setting SERVICE_NAME_SETTING = Setting.simpleString(
+ "cloud.azure.management.cloud.service.name",
+ Property.NodeScope
+ );
// Keystore settings
- public static final Setting KEYSTORE_PATH_SETTING =
- Setting.simpleString("cloud.azure.management.keystore.path", Property.NodeScope, Property.Filtered);
- public static final Setting KEYSTORE_PASSWORD_SETTING =
- Setting.simpleString("cloud.azure.management.keystore.password", Property.NodeScope,
- Property.Filtered);
- public static final Setting KEYSTORE_TYPE_SETTING =
- new Setting<>("cloud.azure.management.keystore.type", KeyStoreType.pkcs12.name(), KeyStoreType::fromString,
- Property.NodeScope, Property.Filtered);
+ public static final Setting KEYSTORE_PATH_SETTING = Setting.simpleString(
+ "cloud.azure.management.keystore.path",
+ Property.NodeScope,
+ Property.Filtered
+ );
+ public static final Setting KEYSTORE_PASSWORD_SETTING = Setting.simpleString(
+ "cloud.azure.management.keystore.password",
+ Property.NodeScope,
+ Property.Filtered
+ );
+ public static final Setting KEYSTORE_TYPE_SETTING = new Setting<>(
+ "cloud.azure.management.keystore.type",
+ KeyStoreType.pkcs12.name(),
+ KeyStoreType::fromString,
+ Property.NodeScope,
+ Property.Filtered
+ );
// so that it can overridden for tests
- public static final Setting ENDPOINT_SETTING = new Setting("cloud.azure.management.endpoint",
- "https://management.core.windows.net/", s -> {
+ public static final Setting ENDPOINT_SETTING = new Setting(
+ "cloud.azure.management.endpoint",
+ "https://management.core.windows.net/",
+ s -> {
try {
return new URI(s);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
- }, Property.NodeScope);
+ },
+ Property.NodeScope
+ );
}
final class Discovery {
- public static final Setting REFRESH_SETTING =
- Setting.positiveTimeSetting("discovery.azure.refresh_interval", TimeValue.timeValueSeconds(0), Property.NodeScope);
- public static final Setting HOST_TYPE_SETTING =
- new Setting<>("discovery.azure.host.type", AzureSeedHostsProvider.HostType.PRIVATE_IP.name(),
- AzureSeedHostsProvider.HostType::fromString, Property.NodeScope);
- public static final Setting ENDPOINT_NAME_SETTING = new Setting<>("discovery.azure.endpoint.name", "opensearch",
- Function.identity(), Property.NodeScope);
- public static final Setting DEPLOYMENT_NAME_SETTING = Setting.simpleString("discovery.azure.deployment.name",
- Property.NodeScope);
- public static final Setting DEPLOYMENT_SLOT_SETTING = new Setting<>("discovery.azure.deployment.slot",
- Deployment.PRODUCTION.name(), Deployment::fromString, Property.NodeScope);
+ public static final Setting REFRESH_SETTING = Setting.positiveTimeSetting(
+ "discovery.azure.refresh_interval",
+ TimeValue.timeValueSeconds(0),
+ Property.NodeScope
+ );
+ public static final Setting HOST_TYPE_SETTING = new Setting<>(
+ "discovery.azure.host.type",
+ AzureSeedHostsProvider.HostType.PRIVATE_IP.name(),
+ AzureSeedHostsProvider.HostType::fromString,
+ Property.NodeScope
+ );
+ public static final Setting ENDPOINT_NAME_SETTING = new Setting<>(
+ "discovery.azure.endpoint.name",
+ "opensearch",
+ Function.identity(),
+ Property.NodeScope
+ );
+ public static final Setting DEPLOYMENT_NAME_SETTING = Setting.simpleString(
+ "discovery.azure.deployment.name",
+ Property.NodeScope
+ );
+ public static final Setting DEPLOYMENT_SLOT_SETTING = new Setting<>(
+ "discovery.azure.deployment.slot",
+ Deployment.PRODUCTION.name(),
+ Deployment::fromString,
+ Property.NodeScope
+ );
}
HostedServiceGetDetailedResponse getServiceDetails();
diff --git a/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeServiceImpl.java b/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeServiceImpl.java
index 093128c0a1392..6a8b8d83f539b 100644
--- a/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeServiceImpl.java
+++ b/plugins/discovery-azure-classic/src/main/java/org/opensearch/cloud/azure/classic/management/AzureComputeServiceImpl.java
@@ -56,11 +56,9 @@
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
-public class AzureComputeServiceImpl extends AbstractLifecycleComponent
- implements AzureComputeService {
+public class AzureComputeServiceImpl extends AbstractLifecycleComponent implements AzureComputeService {
private static final Logger logger = LogManager.getLogger(AzureComputeServiceImpl.class);
-
private final ComputeManagementClient client;
private final String serviceName;
@@ -89,8 +87,15 @@ public AzureComputeServiceImpl(Settings settings) {
Configuration configuration = new Configuration(builder);
configuration.setProperty(Configuration.PROPERTY_LOG_HTTP_REQUESTS, logger.isTraceEnabled());
- Configuration managementConfig = ManagementConfiguration.configure(null, configuration,
- Management.ENDPOINT_SETTING.get(settings), subscriptionId, keystorePath, keystorePassword, keystoreType);
+ Configuration managementConfig = ManagementConfiguration.configure(
+ null,
+ configuration,
+ Management.ENDPOINT_SETTING.get(settings),
+ subscriptionId,
+ keystorePath,
+ keystorePassword,
+ keystoreType
+ );
logger.debug("creating new Azure client for [{}], [{}]", subscriptionId, serviceName);
client = ComputeManagementService.create(managementConfig);
@@ -111,20 +116,20 @@ private static String getRequiredSetting(Settings settings, Setting sett
public HostedServiceGetDetailedResponse getServiceDetails() {
SpecialPermission.check();
try {
- return AccessController.doPrivileged((PrivilegedExceptionAction)
- () -> client.getHostedServicesOperations().getDetailed(serviceName));
+ return AccessController.doPrivileged(
+ (PrivilegedExceptionAction) () -> client.getHostedServicesOperations()
+ .getDetailed(serviceName)
+ );
} catch (PrivilegedActionException e) {
throw new AzureServiceRemoteException("can not get list of azure nodes", e.getCause());
}
}
@Override
- protected void doStart() throws OpenSearchException {
- }
+ protected void doStart() throws OpenSearchException {}
@Override
- protected void doStop() throws OpenSearchException {
- }
+ protected void doStop() throws OpenSearchException {}
@Override
protected void doClose() throws OpenSearchException {
diff --git a/plugins/discovery-azure-classic/src/main/java/org/opensearch/discovery/azure/classic/AzureSeedHostsProvider.java b/plugins/discovery-azure-classic/src/main/java/org/opensearch/discovery/azure/classic/AzureSeedHostsProvider.java
index 9bcfbdd1907d9..0fe6904e83242 100644
--- a/plugins/discovery-azure-classic/src/main/java/org/opensearch/discovery/azure/classic/AzureSeedHostsProvider.java
+++ b/plugins/discovery-azure-classic/src/main/java/org/opensearch/discovery/azure/classic/AzureSeedHostsProvider.java
@@ -61,17 +61,17 @@
import java.util.List;
public class AzureSeedHostsProvider implements SeedHostsProvider {
-
+
private static final Logger logger = LogManager.getLogger(AzureSeedHostsProvider.class);
public enum HostType {
PRIVATE_IP("private_ip"),
PUBLIC_IP("public_ip");
- private String type ;
+ private String type;
HostType(String type) {
- this.type = type ;
+ this.type = type;
}
public String getType() {
@@ -123,8 +123,12 @@ public static Deployment fromString(String string) {
private final String deploymentName;
private final DeploymentSlot deploymentSlot;
- public AzureSeedHostsProvider(Settings settings, AzureComputeService azureComputeService,
- TransportService transportService, NetworkService networkService) {
+ public AzureSeedHostsProvider(
+ Settings settings,
+ AzureComputeService azureComputeService,
+ TransportService transportService,
+ NetworkService networkService
+ ) {
this.settings = settings;
this.azureComputeService = azureComputeService;
this.transportService = transportService;
@@ -152,8 +156,8 @@ public AzureSeedHostsProvider(Settings settings, AzureComputeService azureComput
@Override
public List getSeedAddresses(HostsResolver hostsResolver) {
if (refreshInterval.millis() != 0) {
- if (dynamicHosts != null &&
- (refreshInterval.millis() < 0 || (System.currentTimeMillis() - lastRefresh) < refreshInterval.millis())) {
+ if (dynamicHosts != null
+ && (refreshInterval.millis() < 0 || (System.currentTimeMillis() - lastRefresh) < refreshInterval.millis())) {
logger.trace("using cache to retrieve node list");
return dynamicHosts;
}
@@ -179,7 +183,8 @@ public List getSeedAddresses(HostsResolver hostsResolver) {
InetAddress ipAddress = null;
try {
ipAddress = networkService.resolvePublishHostAddresses(
- NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY));
+ NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY)
+ );
logger.trace("ip of current node: [{}]", ipAddress);
} catch (IOException e) {
// We can't find the publish host address... Hmmm. Too bad :-(
@@ -189,24 +194,26 @@ public List getSeedAddresses(HostsResolver hostsResolver) {
for (HostedServiceGetDetailedResponse.Deployment deployment : detailed.getDeployments()) {
// We check the deployment slot
if (deployment.getDeploymentSlot() != deploymentSlot) {
- logger.debug("current deployment slot [{}] for [{}] is different from [{}]. skipping...",
- deployment.getDeploymentSlot(), deployment.getName(), deploymentSlot);
+ logger.debug(
+ "current deployment slot [{}] for [{}] is different from [{}]. skipping...",
+ deployment.getDeploymentSlot(),
+ deployment.getName(),
+ deploymentSlot
+ );
continue;
}
// If provided, we check the deployment name
if (Strings.hasLength(deploymentName) && !deploymentName.equals(deployment.getName())) {
- logger.debug("current deployment name [{}] different from [{}]. skipping...",
- deployment.getName(), deploymentName);
+ logger.debug("current deployment name [{}] different from [{}]. skipping...", deployment.getName(), deploymentName);
continue;
}
// We check current deployment status
- if (deployment.getStatus() != DeploymentStatus.Starting &&
- deployment.getStatus() != DeploymentStatus.Deploying &&
- deployment.getStatus() != DeploymentStatus.Running) {
- logger.debug("[{}] status is [{}]. skipping...",
- deployment.getName(), deployment.getStatus());
+ if (deployment.getStatus() != DeploymentStatus.Starting
+ && deployment.getStatus() != DeploymentStatus.Deploying
+ && deployment.getStatus() != DeploymentStatus.Running) {
+ logger.debug("[{}] status is [{}]. skipping...", deployment.getName(), deployment.getStatus());
continue;
}
diff --git a/plugins/discovery-azure-classic/src/main/java/org/opensearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java b/plugins/discovery-azure-classic/src/main/java/org/opensearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java
index f50a37f11aab7..fabe8356812a4 100644
--- a/plugins/discovery-azure-classic/src/main/java/org/opensearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java
+++ b/plugins/discovery-azure-classic/src/main/java/org/opensearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java
@@ -71,31 +71,36 @@ protected AzureComputeService createComputeService() {
}
@Override
- public Map> getSeedHostProviders(TransportService transportService,
- NetworkService networkService) {
- return Collections.singletonMap(AZURE,
- () -> createSeedHostsProvider(settings, createComputeService(), transportService, networkService));
+ public Map> getSeedHostProviders(TransportService transportService, NetworkService networkService) {
+ return Collections.singletonMap(
+ AZURE,
+ () -> createSeedHostsProvider(settings, createComputeService(), transportService, networkService)
+ );
}
// Used for testing
- protected AzureSeedHostsProvider createSeedHostsProvider(final Settings settings,
- final AzureComputeService azureComputeService,
- final TransportService transportService,
- final NetworkService networkService) {
+ protected AzureSeedHostsProvider createSeedHostsProvider(
+ final Settings settings,
+ final AzureComputeService azureComputeService,
+ final TransportService transportService,
+ final NetworkService networkService
+ ) {
return new AzureSeedHostsProvider(settings, azureComputeService, transportService, networkService);
}
@Override
public List> getSettings() {
- return Arrays.asList(AzureComputeService.Discovery.REFRESH_SETTING,
- AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING,
- AzureComputeService.Management.KEYSTORE_PATH_SETTING,
- AzureComputeService.Management.KEYSTORE_TYPE_SETTING,
- AzureComputeService.Management.SUBSCRIPTION_ID_SETTING,
- AzureComputeService.Management.SERVICE_NAME_SETTING,
- AzureComputeService.Discovery.HOST_TYPE_SETTING,
- AzureComputeService.Discovery.DEPLOYMENT_NAME_SETTING,
- AzureComputeService.Discovery.DEPLOYMENT_SLOT_SETTING,
- AzureComputeService.Discovery.ENDPOINT_NAME_SETTING);
+ return Arrays.asList(
+ AzureComputeService.Discovery.REFRESH_SETTING,
+ AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING,
+ AzureComputeService.Management.KEYSTORE_PATH_SETTING,
+ AzureComputeService.Management.KEYSTORE_TYPE_SETTING,
+ AzureComputeService.Management.SUBSCRIPTION_ID_SETTING,
+ AzureComputeService.Management.SERVICE_NAME_SETTING,
+ AzureComputeService.Discovery.HOST_TYPE_SETTING,
+ AzureComputeService.Discovery.DEPLOYMENT_NAME_SETTING,
+ AzureComputeService.Discovery.DEPLOYMENT_SLOT_SETTING,
+ AzureComputeService.Discovery.ENDPOINT_NAME_SETTING
+ );
}
}
diff --git a/plugins/discovery-azure-classic/src/yamlRestTest/java/org/opensearch/discovery/azure/classic/DiscoveryAzureClassicClientYamlTestSuiteIT.java b/plugins/discovery-azure-classic/src/yamlRestTest/java/org/opensearch/discovery/azure/classic/DiscoveryAzureClassicClientYamlTestSuiteIT.java
index 9c36883b49525..cb9648065067b 100644
--- a/plugins/discovery-azure-classic/src/yamlRestTest/java/org/opensearch/discovery/azure/classic/DiscoveryAzureClassicClientYamlTestSuiteIT.java
+++ b/plugins/discovery-azure-classic/src/yamlRestTest/java/org/opensearch/discovery/azure/classic/DiscoveryAzureClassicClientYamlTestSuiteIT.java
@@ -49,4 +49,3 @@ public static Iterable