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

Deprecate public class names with master terminology #3871

Merged
merged 15 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 9 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
13 changes: 8 additions & 5 deletions server/src/main/java/org/opensearch/OpenSearchException.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
package org.opensearch;

import org.opensearch.action.support.replication.ReplicationOperation;
import org.opensearch.cluster.NotClusterManagerException;
import org.opensearch.cluster.action.shard.ShardStateAction;
import org.opensearch.common.CheckedFunction;
import org.opensearch.common.Nullable;
Expand All @@ -47,7 +46,6 @@
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentParseException;
import org.opensearch.common.xcontent.XContentParser;
import org.opensearch.discovery.ClusterManagerNotDiscoveredException;
import org.opensearch.index.Index;
import org.opensearch.index.shard.ShardId;
import org.opensearch.rest.RestStatus;
Expand Down Expand Up @@ -791,8 +789,8 @@ private enum OpenSearchExceptionHandle {
UNKNOWN_VERSION_ADDED
),
CLUSTER_MANAGER_NOT_DISCOVERED_EXCEPTION(
ClusterManagerNotDiscoveredException.class,
ClusterManagerNotDiscoveredException::new,
org.opensearch.discovery.ClusterManagerNotDiscoveredException.class,
org.opensearch.discovery.ClusterManagerNotDiscoveredException::new,
3,
UNKNOWN_VERSION_ADDED
),
Expand Down Expand Up @@ -1501,7 +1499,12 @@ private enum OpenSearchExceptionHandle {
143,
UNKNOWN_VERSION_ADDED
),
NOT_CLUSTER_MANAGER_EXCEPTION(NotClusterManagerException.class, NotClusterManagerException::new, 144, UNKNOWN_VERSION_ADDED),
NOT_CLUSTER_MANAGER_EXCEPTION(
org.opensearch.cluster.NotClusterManagerException.class,
org.opensearch.cluster.NotClusterManagerException::new,
144,
UNKNOWN_VERSION_ADDED
),
STATUS_EXCEPTION(
org.opensearch.OpenSearchStatusException.class,
org.opensearch.OpenSearchStatusException::new,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public void onNoLongerMaster(String source) {
"stopped being cluster-manager while waiting for events with priority [{}]. retrying.",
request.waitForEvents()
);
// TransportClusterManagerNodeAction implements the retry logic, which is triggered by passing a
// NotClusterManagerException
// TransportClusterManagerNodeAction implements the retry logic,
// which is triggered by passing a NotClusterManagerException
listener.onFailure(new NotClusterManagerException("no longer cluster-manager. source: [" + source + "]"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster;

/**
* Enables listening to cluster-manager changes events of the local node (when the local node becomes the cluster-manager, and when the local
* node cease being a cluster-manager).
*
* @opensearch.internal
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link LocalNodeClusterManagerListener}
*/
@Deprecated
public interface LocalNodeMasterListener extends LocalNodeClusterManagerListener {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster;

import java.util.function.Predicate;

/**
* Utility class to build a predicate that accepts cluster state changes
*
* @opensearch.internal
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link ClusterManagerNodeChangePredicate}
*/
@Deprecated
public final class MasterNodeChangePredicate {

private MasterNodeChangePredicate() {

}

public static Predicate<ClusterState> build(ClusterState currentState) {
return ClusterManagerNodeChangePredicate.build(currentState);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster;

import org.opensearch.common.io.stream.StreamInput;

import java.io.IOException;

/**
* Thrown when a node join request or a cluster-manager ping reaches a node which is not
* currently acting as a cluster-manager or when a cluster state update task is to be executed
* on a node that is no longer cluster-manager.
*
* @opensearch.internal
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link NotClusterManagerException}
*/
@Deprecated
public class NotMasterException extends NotClusterManagerException {

public NotMasterException(String msg) {
super(msg);
}

public NotMasterException(StreamInput in) throws IOException {
super(in);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ public class JoinHelper {
@Override
public ClusterTasksResult<JoinTaskExecutor.Task> execute(ClusterState currentState, List<JoinTaskExecutor.Task> joiningTasks)
throws Exception {
// The current state that ClusterManagerService uses might have been updated by a (different) cluster-manager in a higher
// term
// already
// The current state that ClusterManagerService uses might have been updated by a (different) cluster-manager
// in a higher term already
// Stop processing the current cluster state update, as there's no point in continuing to compute it as
// it will later be rejected by Coordinator.publish(...) anyhow
if (currentState.term() > term) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster.coordination;

import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;

/**
* Service to block the master node
*
* @opensearch.internal
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link NoClusterManagerBlockService}
*/
@Deprecated
public class NoMasterBlockService extends NoClusterManagerBlockService {

public NoMasterBlockService(Settings settings, ClusterSettings clusterSettings) {
super(settings, clusterSettings);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster.coordination;

/**
* Tool to run an unsafe bootstrap
*
* @opensearch.internal
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link UnsafeBootstrapClusterManagerCommand}
*/
@Deprecated
public class UnsafeBootstrapMasterCommand extends UnsafeBootstrapClusterManagerCommand {

UnsafeBootstrapMasterCommand() {
super();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.cluster.service;

import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.threadpool.ThreadPool;

/**
* Main Master Node Service
*
* @opensearch.internal
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link ClusterManagerService}
*/
@Deprecated
public class MasterService extends ClusterManagerService {

public MasterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) {
super(settings, clusterSettings, threadPool);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one problem, the return value of getMasterService() should be the old MasterService class, otherwise there will be down-casting problem for the existing classes that uses the return value.
https://github.com/tlfeng/OpenSearch/blob/951af92cb316bf0d9f1b56338fd0bec90d029375/server/src/main/java/org/opensearch/cluster/service/ClusterService.java#L221

    public ClusterManagerService getMasterService() {
        return clusterManagerService;
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I reverted renaming the class MasterService in this PR (in commit 50a322b).

}
Loading