Merge branch 'master' into license-checking/reporting-ux

Original commit: elastic/x-pack-elasticsearch@b4c892a0c9
This commit is contained in:
Shaunak Kashyap 2016-06-29 17:57:31 -07:00
commit 3ae999bf41
9 changed files with 90 additions and 68 deletions

View File

@ -9,12 +9,11 @@ import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ActionPlugin.ActionHandler;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.action.GraphExploreAction;
import org.elasticsearch.xpack.graph.action.TransportGraphExploreAction;
@ -57,19 +56,20 @@ public class Graph extends Plugin implements ActionPlugin {
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
if (enabled) {
return singletonList(new ActionHandler<>(GraphExploreAction.INSTANCE, TransportGraphExploreAction.class));
if (false == enabled) {
return emptyList();
}
return emptyList();
return singletonList(new ActionHandler<>(GraphExploreAction.INSTANCE, TransportGraphExploreAction.class));
}
public void onModule(NetworkModule module) {
if (enabled && transportClientMode == false) {
module.registerRestHandler(RestGraphAction.class);
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
if (false == enabled) {
return emptyList();
}
return singletonList(RestGraphAction.class);
}
@Override
public List<Setting<?>> getSettings() {
return Collections.singletonList(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope));

View File

@ -11,7 +11,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseAction;
@ -26,6 +25,7 @@ import org.elasticsearch.license.plugin.rest.RestDeleteLicenseAction;
import org.elasticsearch.license.plugin.rest.RestGetLicenseAction;
import org.elasticsearch.license.plugin.rest.RestPutLicenseAction;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestHandler;
import java.util.Arrays;
import java.util.Collection;
@ -53,14 +53,6 @@ public class Licensing implements ActionPlugin {
isTribeNode = isTribeNode(settings);
}
public void onModule(NetworkModule module) {
if (isTransportClient == false && isTribeNode == false) {
module.registerRestHandler(RestPutLicenseAction.class);
module.registerRestHandler(RestGetLicenseAction.class);
module.registerRestHandler(RestDeleteLicenseAction.class);
}
}
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
if (isTribeNode) {
@ -71,6 +63,16 @@ public class Licensing implements ActionPlugin {
new ActionHandler<>(DeleteLicenseAction.INSTANCE, TransportDeleteLicenseAction.class));
}
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
if (isTribeNode) {
return emptyList();
}
return Arrays.asList(RestPutLicenseAction.class,
RestGetLicenseAction.class,
RestDeleteLicenseAction.class);
}
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
if (isTransportClient == false && isTribeNode == false) {
return Collections.<Class<? extends LifecycleComponent>>singletonList(LicensesService.class);

View File

@ -21,6 +21,7 @@ import org.elasticsearch.xpack.monitoring.cleaner.CleanerService;
import org.elasticsearch.xpack.monitoring.client.MonitoringClientModule;
import org.elasticsearch.xpack.monitoring.rest.action.RestMonitoringBulkAction;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.XPackPlugin;
import java.util.ArrayList;
@ -84,16 +85,18 @@ public class Monitoring implements ActionPlugin {
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
if (enabled && tribeNode == false) {
return singletonList(new ActionHandler<>(MonitoringBulkAction.INSTANCE, TransportMonitoringBulkAction.class));
if (false == enabled || tribeNode) {
return emptyList();
}
return emptyList();
return singletonList(new ActionHandler<>(MonitoringBulkAction.INSTANCE, TransportMonitoringBulkAction.class));
}
public void onModule(NetworkModule module) {
if (enabled && transportClientMode == false && tribeNode == false) {
module.registerRestHandler(RestMonitoringBulkAction.class);
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
if (false == enabled || tribeNode) {
return emptyList();
}
return singletonList(RestMonitoringBulkAction.class);
}
public static boolean enabled(Settings settings) {

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring.agent.collector;
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.carrotsearch.randomizedtesting.SysGlobals;
import org.elasticsearch.action.ActionModule;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.block.ClusterBlocks;
@ -26,14 +25,13 @@ import org.elasticsearch.license.plugin.core.Licensee;
import org.elasticsearch.license.plugin.core.LicenseeRegistry;
import org.elasticsearch.license.plugin.core.LicensesManagerService;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ActionPlugin.ActionHandler;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.security.InternalClient;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
import org.elasticsearch.xpack.monitoring.test.MonitoringIntegTestCase;
import org.elasticsearch.xpack.security.InternalClient;
import org.junit.Before;
import java.util.ArrayList;
@ -205,11 +203,12 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
}
@Override
public void onModule(NetworkModule module) {
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
return emptyList();
}
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
public List<Class<? extends RestHandler>> getRestHandlers() {
return emptyList();
}

View File

@ -12,7 +12,6 @@ import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.Licensing;
@ -21,7 +20,7 @@ import org.elasticsearch.license.plugin.core.Licensee;
import org.elasticsearch.license.plugin.core.LicenseeRegistry;
import org.elasticsearch.license.plugin.core.LicensesManagerService;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ActionPlugin.ActionHandler;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.monitoring.MonitoringLicensee;
@ -96,11 +95,12 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
}
@Override
public void onModule(NetworkModule module) {
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
return emptyList();
}
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
public List<Class<? extends RestHandler>> getRestHandlers() {
return emptyList();
}

View File

@ -23,6 +23,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.security.action.SecurityActionModule;
import org.elasticsearch.xpack.security.action.filter.SecurityActionFilter;
@ -308,6 +309,23 @@ public class Security implements ActionPlugin {
return emptyList();
}
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
if (enabled == false) {
return emptyList();
}
return Arrays.asList(RestAuthenticateAction.class,
RestClearRealmCacheAction.class,
RestClearRolesCacheAction.class,
RestGetUsersAction.class,
RestPutUserAction.class,
RestDeleteUserAction.class,
RestGetRolesAction.class,
RestPutRoleAction.class,
RestDeleteRoleAction.class,
RestChangePasswordAction.class);
}
public void onModule(NetworkModule module) {
if (transportClientMode) {
@ -321,16 +339,6 @@ public class Security implements ActionPlugin {
if (enabled) {
module.registerTransport(Security.NAME, SecurityNettyTransport.class);
module.registerTransportService(Security.NAME, SecurityServerTransportService.class);
module.registerRestHandler(RestAuthenticateAction.class);
module.registerRestHandler(RestClearRealmCacheAction.class);
module.registerRestHandler(RestClearRolesCacheAction.class);
module.registerRestHandler(RestGetUsersAction.class);
module.registerRestHandler(RestPutUserAction.class);
module.registerRestHandler(RestDeleteUserAction.class);
module.registerRestHandler(RestGetRolesAction.class);
module.registerRestHandler(RestPutRoleAction.class);
module.registerRestHandler(RestDeleteRoleAction.class);
module.registerRestHandler(RestChangePasswordAction.class);
module.registerHttpTransport(Security.NAME, SecurityNettyHttpServerTransport.class);
}
}

View File

@ -32,6 +32,7 @@ import org.elasticsearch.license.plugin.Licensing;
import org.elasticsearch.license.plugin.core.LicenseState;
import org.elasticsearch.license.plugin.core.Licensee;
import org.elasticsearch.license.plugin.core.LicenseeRegistry;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.SecuritySettingsSource;
@ -272,11 +273,12 @@ public class LicensingTests extends SecurityIntegTestCase {
}
@Override
public void onModule(NetworkModule module) {
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
return emptyList();
}
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
public List<Class<? extends RestHandler>> getRestHandlers() {
return emptyList();
}

View File

@ -26,6 +26,7 @@ import org.elasticsearch.xpack.monitoring.MonitoringSettings;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.xpack.action.TransportXPackInfoAction;
@ -212,15 +213,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin {
}
public void onModule(NetworkModule module) {
if (!transportClientMode) {
module.registerRestHandler(RestXPackInfoAction.class);
module.registerRestHandler(RestXPackUsageAction.class);
}
licensing.onModule(module);
monitoring.onModule(module);
security.onModule(module);
watcher.onModule(module);
graph.onModule(module);
}
@Override
@ -247,6 +240,19 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin {
return filters;
}
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
List<Class<? extends RestHandler>> handlers = new ArrayList<>();
handlers.add(RestXPackInfoAction.class);
handlers.add(RestXPackUsageAction.class);
handlers.addAll(licensing.getRestHandlers());
handlers.addAll(monitoring.getRestHandlers());
handlers.addAll(security.getRestHandlers());
handlers.addAll(watcher.getRestHandlers());
handlers.addAll(graph.getRestHandlers());
return handlers;
}
public void onModule(AuthenticationModule module) {
if (extensionsService != null) {
extensionsService.onModule(module);

View File

@ -16,12 +16,12 @@ import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.rest.RestHandler;
import org.elasticsearch.threadpool.ExecutorBuilder;
import org.elasticsearch.threadpool.FixedExecutorBuilder;
import org.elasticsearch.xpack.XPackPlugin;
@ -178,20 +178,6 @@ public class Watcher implements ActionPlugin {
return Collections.emptyList();
}
public void onModule(NetworkModule module) {
if (enabled && transportClient == false) {
module.registerRestHandler(RestPutWatchAction.class);
module.registerRestHandler(RestDeleteWatchAction.class);
module.registerRestHandler(RestWatcherStatsAction.class);
module.registerRestHandler(RestGetWatchAction.class);
module.registerRestHandler(RestWatchServiceAction.class);
module.registerRestHandler(RestAckWatchAction.class);
module.registerRestHandler(RestActivateWatchAction.class);
module.registerRestHandler(RestExecuteWatchAction.class);
module.registerRestHandler(RestHijackOperationAction.class);
}
}
@Override
public List<ActionHandler<? extends ActionRequest<?>, ? extends ActionResponse>> getActions() {
if (false == enabled) {
@ -207,6 +193,22 @@ public class Watcher implements ActionPlugin {
new ActionHandler<>(ExecuteWatchAction.INSTANCE, TransportExecuteWatchAction.class));
}
@Override
public List<Class<? extends RestHandler>> getRestHandlers() {
if (false == enabled) {
return emptyList();
}
return Arrays.asList(RestPutWatchAction.class,
RestDeleteWatchAction.class,
RestWatcherStatsAction.class,
RestGetWatchAction.class,
RestWatchServiceAction.class,
RestAckWatchAction.class,
RestActivateWatchAction.class,
RestExecuteWatchAction.class,
RestHijackOperationAction.class);
}
public static boolean enabled(Settings settings) {
return XPackPlugin.featureEnabled(settings, NAME, true);
}