All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gemstone.gemfire.admin.AdminDistributedSystemFactory Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * Licensed 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. See accompanying
 * LICENSE file.
 */
package com.gemstone.gemfire.admin;

import com.gemstone.gemfire.admin.internal.DistributedSystemConfigImpl;
import com.gemstone.gemfire.admin.internal.AdminDistributedSystemImpl;
import com.gemstone.gemfire.distributed.DistributedSystem;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.i18n.LogWriterI18n;
import com.gemstone.gemfire.internal.LocalLogWriter;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;

import java.util.Properties;

/**
 * Factory for creating GemFire administration entities. 
 *
 * @author    Kirk Lund
 * @since     3.5
 * @deprecated as of 7.0 use the {@link com.gemstone.gemfire.management} package instead
 */
public class AdminDistributedSystemFactory {
  
  /**
   * Sets the address this VM should bind to when connecting to the distributed
   * system.  This involves a system property, so using this option will limit
   * all connections to distributed systems to this one network interface.
   * 

* Using a null or empty bindAddress will clear the usage of this option and * connections to distributed systems will return to using all available * network interfaces. *

* This method always throws UnsupportedOperationException because it is * now deprecated and is unsafe to use. Please use {@link * DistributedSystemConfig#setBindAddress} instead. * * @param bindAddress machine name or IP address to bind to * @throws UnsupportedOperationException because of deprecation * @deprecated Use {@link DistributedSystemConfig#setBindAddress} instead. */ @Deprecated public static void bindToAddress(String bindAddress) { throw new UnsupportedOperationException(LocalizedStrings.AdminDistributedSystemFactory_PLEASE_USE_DISTRIBUTEDSYSTEMCONFIGSETBINDADDRESS_INSTEAD.toLocalizedString()); } /** * Defines a "default" distributed system configuration based on VM * system properties and the content of * gemfire.properties. The {@linkplain * DistributedSystemConfig#DEFAULT_REMOTE_COMMAND} default remote * command is used. * * @see DistributedSystem#connect */ public static DistributedSystemConfig defineDistributedSystem() { DistributionConfig dc = new DistributionConfigImpl(new Properties()); String remoteCommand = DistributedSystemConfig.DEFAULT_REMOTE_COMMAND; return new DistributedSystemConfigImpl(dc, remoteCommand); } /** * Call this method with a value of true * to dedicate the VM to GemFire administration only. * Default is false. *

This method must be called before calling * {@link AdminDistributedSystem#connect}. It must also be called * before {@link DistributedSystem#connect} is when creating a colocated distributed system. *

* Once it has been enabled be careful to only use GemFire APIs from the * com.gemstone.gemfire.admin package. In particular do not create * a {@link com.gemstone.gemfire.cache.Cache} or a normal {@link DistributedSystem}. * @param adminOnly true if this VM should be limited to administration APIs; * false if this VM should allow all GemFire APIs. * @throws IllegalStateException if a {@link DistributedSystem} * or {@link AdminDistributedSystem} connection already exists. * * @since 5.7 */ public static void setEnableAdministrationOnly(boolean adminOnly) { InternalDistributedSystem.setEnableAdministrationOnly(adminOnly); } /** * Defines a distributed system configuration for administering the * distributed system to which this VM is currently connected. The * DistributedSystem is used to configure the discovery * mechanism (multicast or locators), bind address, SSL attributes, * as well as the logger of the * DistributedSystemConfig. Note that the distributed * system will not be able to be administered until the {@link * AdminDistributedSystem#connect connect} method is invoked. * * @param system * A connection to the distributed system * @param remoteCommand * The shell command that is used to launch processes that * run on remote machines. If null, then the * {@linkplain DistributedSystemConfig#DEFAULT_REMOTE_COMMAND * default} will be used. * * @since 4.0 */ public static DistributedSystemConfig defineDistributedSystem(DistributedSystem system, String remoteCommand) throws AdminException { InternalDistributedSystem internal = (InternalDistributedSystem) system; if (remoteCommand == null) { remoteCommand = DistributedSystemConfig.DEFAULT_REMOTE_COMMAND; } DistributedSystemConfigImpl impl = new DistributedSystemConfigImpl(internal.getConfig(), remoteCommand); impl.setLogWriter(system.getLogWriter().convertToLogWriterI18n()); return impl; } /** * Returns the distributed system for administrative monitoring and * managing. You must then call {@link * AdminDistributedSystem#connect} before interacting with the * actual system. * * @param config configuration definition of the system to administer * @return administrative interface for a distributed system */ public static AdminDistributedSystem getDistributedSystem(DistributedSystemConfig config) { return new AdminDistributedSystemImpl(config); } /** * Returns a default GemFire LogWriterI18n for logging. This LogWriterI18n will * log to standard out. * * @return a GemFire LogWriterI18n for logging */ public static LogWriterI18n getLogWriter() { return new LocalLogWriter(DistributionConfig.DEFAULT_LOG_LEVEL); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy