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

Fix a few more renaming issues. #464

Merged
merged 1 commit into from
Mar 26, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class InternalDistributionArchiveCheckPluginFuncTest extends AbstractGradleFuncT
def "fails on unexpected notice content"() {
given:
license(file("LICENSE.txt"))
file("NOTICE.txt").text = """Elasticsearch
file("NOTICE.txt").text = """OpenSearch
Copyright 2009-2018 Acme Coorp"""
buildFile << """
apply plugin:'base'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
private static final String FAKE_SNAPSHOT_IVY_GROUP = "opensearch-distribution-snapshot";
private static final String DOWNLOAD_REPO_NAME = "opensearch-downloads";
private static final String SNAPSHOT_REPO_NAME = "opensearch-snapshots";
public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "es_distro_extracted_";
public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "opensearch_distro_extracted_";

private NamedDomainObjectContainer<OpenSearchDistribution> distributionsContainer;
private NamedDomainObjectContainer<DistributionResolution> distributionsResolutionStrategiesContainer;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void apply(Project project) {

private void setupDistributionContainer(Project project, Provider<DockerSupportService> dockerSupport) {
distributionsContainer = project.container(OpenSearchDistribution.class, name -> {
Configuration fileConfiguration = project.getConfigurations().create("es_distro_file_" + name);
Configuration fileConfiguration = project.getConfigurations().create("opensearch_distro_file_" + name);
Configuration extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name);
extractedConfiguration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
return new OpenSearchDistribution(name, project.getObjects(), dockerSupport, fileConfiguration, extractedConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
public class OpenSearchNode implements TestClusterConfiguration {

private static final Logger LOGGER = Logging.getLogger(OpenSearchNode.class);
private static final int ES_DESTROY_TIMEOUT = 20;
private static final TimeUnit ES_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS;
private static final int OPENSEARCH_DESTROY_TIMEOUT = 20;
private static final TimeUnit OPENSEARCH_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS;

private static final int NODE_UP_TIMEOUT = 2;
private static final TimeUnit NODE_UP_TIMEOUT_UNIT = TimeUnit.MINUTES;
Expand Down Expand Up @@ -916,7 +916,11 @@ private void stopHandle(ProcessHandle processHandle, boolean forcibly) {
if (processHandle.isAlive() == false) {
return;
}
LOGGER.info("process did not terminate after {} {}, stopping it forcefully", ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT);
LOGGER.info(
"process did not terminate after {} {}, stopping it forcefully",
OPENSEARCH_DESTROY_TIMEOUT,
OPENSEARCH_DESTROY_TIMEOUT_UNIT
);
processHandle.destroyForcibly();
}

Expand Down Expand Up @@ -1007,7 +1011,7 @@ private String normalizeLogLine(String line) {

private void waitForProcessToExit(ProcessHandle processHandle) {
try {
processHandle.onExit().get(ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT);
processHandle.onExit().get(OPENSEARCH_DESTROY_TIMEOUT, OPENSEARCH_DESTROY_TIMEOUT_UNIT);
} catch (InterruptedException e) {
LOGGER.info("Interrupted while waiting for ES process", e);
Thread.currentThread().interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private NamedDomainObjectContainer<OpenSearchCluster> createTestClustersContaine
private void createListClustersTask(Project project, NamedDomainObjectContainer<OpenSearchCluster> container) {
// Task is never up to date so we can pass an lambda for the task action
project.getTasks().register(LIST_TASK_NAME, task -> {
task.setGroup("ES cluster formation");
task.setDescription("Lists all ES clusters configured for this project");
task.setGroup("OpenSearch cluster formation");
task.setDescription("Lists all OpenSearch clusters configured for this project");
task.doLast(
(Task t) -> container.forEach(cluster -> logger.lifecycle(" * {}: {}", cluster.getName(), cluster.getNumberOfNodes()))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class Sniffer implements Closeable {

private static final Log logger = LogFactory.getLog(Sniffer.class);
private static final String SNIFFER_THREAD_NAME = "es_rest_client_sniffer";
private static final String SNIFFER_THREAD_NAME = "opensearch_rest_client_sniffer";

private final NodesSniffer nodesSniffer;
private final RestClient restClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public void run() {

}
});
assertThat(thread.getName(), equalTo("es_rest_client_sniffer[T#" + i + "]"));
assertThat(thread.getName(), equalTo("opensearch_rest_client_sniffer[T#" + i + "]"));
assertThat(thread.isDaemon(), is(true));
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ private PluginInfo installPlugin(Terminal terminal, boolean isBatch, Path tmpRoo
throws Exception {
final PluginInfo info = loadPluginInfo(terminal, tmpRoot, env);
// read optional security policy (extra permissions), if it exists, confirm or warn the user
Path policy = tmpRoot.resolve(PluginInfo.ES_PLUGIN_POLICY);
Path policy = tmpRoot.resolve(PluginInfo.OPENSEARCH_PLUGIN_POLICY);
final Set<String> permissions;
if (Files.exists(policy)) {
permissions = PluginSecurity.parsePermissions(policy, env.tmpFile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ public void testMissingDescriptor() throws Exception {
public void testContainsIntermediateDirectory() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
Path pluginDir = createPluginDir(temp);
Files.createFile(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES));
Files.createFile(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES));
String pluginZip = writeZip(pluginDir, "opensearch").toUri().toURL().toString();
UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1()));
assertThat(e.getMessage(), containsString("This plugin was built with an older plugin structure"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ public void testPluginWithoutDescriptorFile() throws Exception {
final Path pluginDir = env.pluginsFile().resolve("fake1");
Files.createDirectories(pluginDir);
NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> listPlugins(home));
assertEquals(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString(), e.getFile());
assertEquals(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES).toString(), e.getFile());
}

public void testPluginWithWrongDescriptorFile() throws Exception {
final Path pluginDir = env.pluginsFile().resolve("fake1");
PluginTestUtil.writePluginProperties(pluginDir, "description", "fake desc");
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> listPlugins(home));
final Path descriptorPath = pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES);
final Path descriptorPath = pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES);
assertEquals("property [name] is missing in [" + descriptorPath.toString() + "]", e.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,20 @@ public List<TransportAddress> getSeedAddresses(HostsResolver hostsResolver) {
logger.trace("current node found. Ignoring {} - {}", name, ip_private);
} else {
String address = ip_private;
// Test if we have es_port metadata defined here
if (instance.getMetadata() != null && instance.getMetadata().containsKey("es_port")) {
Object es_port = instance.getMetadata().get("es_port");
logger.trace("es_port is defined with {}", es_port);
if (es_port instanceof String) {
address = address.concat(":").concat((String) es_port);
// Test if we have opensearch_port metadata defined here
if (instance.getMetadata() != null && instance.getMetadata().containsKey("opensearch_port")) {
Object opensearch_port = instance.getMetadata().get("opensearch_port");
logger.trace("opensearch_port is defined with {}", opensearch_port);
if (opensearch_port instanceof String) {
address = address.concat(":").concat((String) opensearch_port);
} else {
// Ignoring other values
logger.trace("es_port is instance of {}. Ignoring...", es_port.getClass().getName());
logger.trace("opensearch_port is instance of {}. Ignoring...", opensearch_port.getClass().getName());
}
}

// ip_private is a single IP Address. We need to build a TransportAddress from it
// If user has set `es_port` metadata, we don't need to ping all ports
// If user has set `opensearch_port` metadata, we don't need to ping all ports
TransportAddress[] addresses = transportService.addressesFromString(address);

for (TransportAddress transportAddress : addresses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static Map<String,Policy> getPluginPermissions(Environment environment) throws I

// now process each one
for (Path plugin : pluginsAndModules) {
Path policyFile = plugin.resolve(PluginInfo.ES_PLUGIN_POLICY);
Path policyFile = plugin.resolve(PluginInfo.OPENSEARCH_PLUGIN_POLICY);
if (Files.exists(policyFile)) {
// first get a list of URLs for the plugins' jars:
// we resolve symlinks so map is keyed on the normalize codebase name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ private void assertCanWrite() throws IOException {
}

// package private for testing
static final String TEMP_FILE_NAME = ".es_temp_file";
static final String TEMP_FILE_NAME = ".opensearch_temp_file";

private static void tryWriteTempFile(Path path) throws IOException {
if (Files.exists(path)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public StatusInfo getHealth() {

class FsHealthMonitor implements Runnable {

static final String TEMP_FILE_NAME = ".es_temp_file";
static final String TEMP_FILE_NAME = ".opensearch_temp_file";
private byte[] byteToWrite;

FsHealthMonitor(){
Expand Down
6 changes: 3 additions & 3 deletions server/src/main/java/org/opensearch/plugins/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
*/
public class PluginInfo implements Writeable, ToXContentObject {

public static final String ES_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
public static final String ES_PLUGIN_POLICY = "plugin-security.policy";
public static final String OPENSEARCH_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
public static final String OPENSEARCH_PLUGIN_POLICY = "plugin-security.policy";

private final String name;
private final String description;
Expand Down Expand Up @@ -148,7 +148,7 @@ public void writeTo(final StreamOutput out) throws IOException {
* @throws IOException if an I/O exception occurred reading the plugin descriptor
*/
public static PluginInfo readFromProperties(final Path path) throws IOException {
final Path descriptor = path.resolve(ES_PLUGIN_PROPERTIES);
final Path descriptor = path.resolve(OPENSEARCH_PLUGIN_PROPERTIES);

final Map<String, String> propsMap;
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public boolean implies(ProtectionDomain domain, Permission permission) {

// guarantee plugin classes are initialized first, in case they have one-time hacks.
// this just makes unit testing more realistic
for (URL url : Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.ES_PLUGIN_PROPERTIES))) {
for (URL url : Collections.list(
BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES))) {
Properties properties = new Properties();
try (InputStream stream = FileSystemUtils.openFileURLStream(url)) {
properties.load(stream);
Expand Down Expand Up @@ -200,7 +201,8 @@ private static void addClassCodebase(Map<String, URL> codebases, String name, St
*/
@SuppressForbidden(reason = "accesses fully qualified URLs to configure security")
static Map<String,Policy> getPluginPermissions() throws Exception {
List<URL> pluginPolicies = Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.ES_PLUGIN_POLICY));
List<URL> pluginPolicies =
Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.OPENSEARCH_PLUGIN_POLICY));
if (pluginPolicies.isEmpty()) {
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class PluginTestUtil {

public static void writePluginProperties(Path pluginDir, String... stringProps) throws IOException {
writeProperties(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES), stringProps);
writeProperties(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES), stringProps);
}

/** convenience method to write a plugin properties file */
Expand Down