public void setAllHasFields(boolean b) {
   int hasCounter = 0;
   Field thisFields[] = UserSpecifiedRegionAttributes.class.getDeclaredFields();
   for (int i = 0; i < thisFields.length; i++) {
     if (thisFields[i].getName().startsWith("has")) {
       hasCounter++;
       try {
         thisFields[i].setBoolean(this, b);
       } catch (IllegalAccessException ouch) {
         Assert.assertTrue(
             false, "Could not access field" + thisFields[i].getName() + " on " + getClass());
       }
     }
   }
   Assert.assertTrue(hasCounter == HAS_COUNT, "Found " + hasCounter + " methods");
   //    this.hasCacheListeners = b;
   //    this.hasCacheLoader = b;
   //    this.hasCacheWriter = b;
   //    this.hasConcurrencyLevel = b;
   //    this.hasDataPolicy = b;
   //    this.hasDiskDirs = b;
   //    this.hasDiskWriteAttributes = b;
   //    this.hasEarlyAck = b;
   //    this.hasEnableAsyncConflation = b;
   //    this.hasEnableSubscriptionConflation = b;
   //    this.hasEnableGateway = b;
   //    this.hasEntryIdleTimeout = b;
   //    this.hasEntryTimeToLive = b;
   //    this.hasEvictionAttributes = b;
   //    this.hasIgnoreJTA = b;
   //    this.hasIndexMaintenanceSynchronous = b;
   //    this.hasInitialCapacity = b;
   //    this.hasIsLockGrantor = b;
   //    this.hasKeyConstraint = b;
   //    this.hasLoadFactor = b;
   //    this.hasMembershipAttributes = b;
   //    this.hasMulticastEnabled = b;
   //    this.hasPartitionAttributes = b;
   //    this.hasPublisher = b;
   //    this.hasRegionIdleTimeout = b;
   //    this.hasRegionTimeToLive = b;
   //    this.hasScope = b;
   //    this.hasStatisticsEnabled = b;
   //    this.hasSubscriptionAttributes = b;
   //    this.hasValueConstraint = b;
 }
 /**
  * Creates an InetAddress representing the local host. The checked exception <code>
  * java.lang.UnknownHostException</code> is captured and results in an Assertion failure instead.
  *
  * @return InetAddress instance representing the local host
  */
 public static InetAddress createLocalHost() {
   try {
     return SocketCreator.getLocalHost();
   } catch (java.net.UnknownHostException e) {
     logStackTrace(e);
     Assert.assertTrue(false, "Failed to get local host");
     return null; // will never happen
   }
 }
 public String getName() {
   checkForRmiConnection();
   try {
     Assert.assertTrue(this.objectName != null);
     return (String) this.mbs.getAttribute(this.objectName, "systemName");
   } catch (Exception ex) {
     String s = "While getting the name";
     throw new InternalGemFireException(s, ex);
   }
 }
  public void setAlertLevelAsString(String level) {
    checkForRmiConnection();
    try {
      Assert.assertTrue(this.objectName != null);
      this.mbs.setAttribute(this.objectName, new Attribute("alertLevel", level));

    } catch (Exception ex) {
      String s = "While setting the alert level";
      throw new InternalGemFireException(s, ex);
    }
  }
  public void setRemoteCommand(String remoteCommand) {
    checkForRmiConnection();
    try {
      Assert.assertTrue(this.objectName != null);
      this.mbs.setAttribute(this.objectName, new Attribute("remoteCommand", remoteCommand));

    } catch (Exception ex) {
      String s = "While setting the remote command";
      throw new InternalGemFireException(s, ex);
    }
  }
  public int getMcastPort() {
    checkForRmiConnection();
    try {
      Assert.assertTrue(this.objectName != null);
      Integer value = (Integer) this.mbs.getAttribute(this.objectName, "mcastPort");
      return value.intValue();

    } catch (Exception ex) {
      String s = "While getting the mcastPort";
      throw new InternalGemFireException(s, ex);
    }
  }
 /**
  * For Externalizable
  *
  * @see Externalizable
  */
 public void writeExternal(ObjectOutput out) throws IOException {
   //    if (this.transientPort == 0) {
   //      InternalDistributedSystem.getLoggerI18n().warning(
   //          LocalizedStrings.DEBUG,
   //          "externalizing a client ID with zero port: " + this.toString(),
   //          new Exception("Stack trace"));
   //    }
   Assert.assertTrue(this.identity.length <= BYTES_32KB);
   out.writeShort(this.identity.length);
   out.write(this.identity);
   out.writeInt(this.uniqueId);
 }
  public void addMembershipListener(SystemMembershipListener listener) {
    checkForRmiConnection();
    JMXSystemMembershipListener listener2 = new JMXSystemMembershipListener(listener);
    try {
      Assert.assertTrue(this.objectName != null);
      this.mbs.addNotificationListener(
          this.objectName, listener2, null /* filter */, null /* handBack */);

    } catch (Exception ex) {
      String s = "While adding membership listener";
      throw new InternalGemFireException(s, ex);
    }
  }
Example #9
0
  @Override
  public void compile(QCompiler compiler) {
    // resolve children type nodes if any, pushing on stack first
    // collections are pushed as CollectionTypes, but elementTypes are not yet resolved (set to
    // OBJECT_TYPE)
    super.compile(compiler);

    Assert.assertTrue(this.javaType != null ^ this.typeName != null);
    if (this.typeName != null) {
      this.javaType = compiler.resolveType(this.typeName);
    }

    compiler.push(this.javaType);
  }
 /**
  * Converts the string host to an instance of InetAddress. Returns null if the string is empty.
  * Fails Assertion if the conversion would result in <code>java.lang.UnknownHostException</code>.
  *
  * <p>Any leading slashes on host will be ignored.
  *
  * @param host string version the InetAddress
  * @return the host converted to InetAddress instance
  */
 public static InetAddress toInetAddress(String host) {
   if (host == null || host.length() == 0) {
     return null;
   }
   try {
     if (host.indexOf("/") > -1) {
       return InetAddress.getByName(host.substring(host.indexOf("/") + 1));
     } else {
       return InetAddress.getByName(host);
     }
   } catch (java.net.UnknownHostException e) {
     logStackTrace(e);
     Assert.assertTrue(false, "Failed to get InetAddress: " + host);
     return null; // will never happen since the Assert will fail
   }
 }
 public RemoteOperationMessage(
     InternalDistributedMember recipient, String regionPath, ReplyProcessor21 processor) {
   Assert.assertTrue(recipient != null, "RemoteMesssage recipient can not be null");
   setRecipient(recipient);
   this.regionPath = regionPath;
   this.processorId = processor == null ? 0 : processor.getProcessorId();
   if (processor != null && this.isSevereAlertCompatible()) {
     processor.enableSevereAlertProcessing();
   }
   this.txUniqId = TXManagerImpl.getCurrentTXUniqueId();
   TXStateProxy txState = TXManagerImpl.getCurrentTXState();
   if (txState != null && txState.isMemberIdForwardingRequired()) {
     this.txMemberId = txState.getOriginatingMember();
   }
   setIfTransactionDistributed();
 }
  public SystemMember[] getSystemMemberApplications() throws AdminException {
    checkForRmiConnection();
    try {
      ObjectName[] names =
          (ObjectName[])
              this.mbs.invoke(
                  this.objectName, "manageSystemMemberApplications", new Object[0], new String[0]);

      SystemMember[] members = new SystemMember[names.length];
      for (int i = 0; i < names.length; i++) {
        Assert.assertTrue(names[i] != null);
        members[i] = new JMXSystemMember(this.mbs, names[i]);
      }
      return members;

    } catch (Exception ex) {
      String s = "While calling manageSystemMemberApplications";
      throw new InternalGemFireException(s, ex);
    }
  }
  /**
   * Creates a new <code>JMXDistributedSystem</code> with the given <Code>DistributedSystemConfig
   * </code>.
   *
   * @param config The configuration for connecting to the distributed system
   * @param mbs The connection JMX MBean server through which operations are invoked, etc.
   * @param agentName The name of the JMX agent MBean
   */
  public JMXAdminDistributedSystem(
      DistributedSystemConfig config,
      MBeanServerConnection mbs,
      JMXConnector conn,
      final ObjectName agentName) {
    super(mbs, null);
    try {
      this.connector = conn;
      this.agentName = agentName;
      this.mbs.setAttribute(
          agentName, new Attribute("mcastPort", new Integer(config.getMcastPort())));
      this.mbs.setAttribute(agentName, new Attribute("mcastAddress", config.getMcastAddress()));
      this.mbs.setAttribute(agentName, new Attribute("locators", config.getLocators()));
      this.mbs.setAttribute(agentName, new Attribute("bindAddress", config.getBindAddress()));

      this.objectName =
          (ObjectName) this.mbs.invoke(agentName, "connectToSystem", new Object[0], new String[0]);
      Assert.assertTrue(this.objectName != null);

      final MBeanServerConnection mbsc = mbs;
      WaitCriterion ev =
          new WaitCriterion() {
            public boolean done() {
              try {
                return ((Boolean) mbsc.getAttribute(agentName, "connected")).booleanValue();
              } catch (Exception e) {
                throw new InternalGemFireException("mbean error", e);
              }
            }

            public String description() {
              return "agent never connected: " + agentName;
            }
          };
      DistributedTestCase.waitForCriterion(ev, 20 * 1000, 200, true);

    } catch (Exception ex) {
      String s = "While creating a JMXDistributedSystem";
      throw new InternalGemFireException(s, ex);
    }
  }
  public void initHasFields(UserSpecifiedRegionAttributes<K, V> other) {
    Field thisFields[] = UserSpecifiedRegionAttributes.class.getDeclaredFields();
    Object[] emptyArgs = new Object[] {};
    int hasCounter = 0;
    String fieldName = null;
    for (int i = 0; i < thisFields.length; i++) {
      fieldName = thisFields[i].getName();
      if (fieldName.startsWith("has")) {
        hasCounter++;
        boolean bval = false;

        try {
          Method otherMeth = other.getClass().getMethod(fieldName /*, (Class[])null*/);
          bval = ((Boolean) otherMeth.invoke(other, emptyArgs)).booleanValue();
        } catch (NoSuchMethodException darnit) {
          Assert.assertTrue(false, "A has* method accessor is required for field " + fieldName);
        } catch (IllegalAccessException boom) {
          Assert.assertTrue(false, "Could not access method " + fieldName + " on " + getClass());
        } catch (IllegalArgumentException e) {
          Assert.assertTrue(
              false, "Illegal argument trying to set field " + e.getLocalizedMessage());
        } catch (InvocationTargetException e) {
          Assert.assertTrue(false, "Failed trying to invoke method " + e.getLocalizedMessage());
        }

        try {
          thisFields[i].setBoolean(this, bval);
        } catch (IllegalAccessException ouch) {
          Assert.assertTrue(false, "Could not access field" + fieldName + " on " + getClass());
        }
      }
    }
    Assert.assertTrue(
        hasCounter == HAS_COUNT,
        "Expected " + HAS_COUNT + " methods, got " + hasCounter + " last field: " + fieldName);

    //    this.hasCacheListeners = other.hasCacheListeners();
    //    this.hasCacheLoader = other.hasCacheLoader();
    //    this.hasCacheWriter = other.hasCacheWriter();
    //    this.hasConcurrencyLevel = other.hasConcurrencyLevel();
    //    this.hasDataPolicy = other.hasDataPolicy();
    //    this.hasDiskDirs = other.hasDiskDirs();
    //    this.hasDiskWriteAttributes = other.hasDiskWriteAttributes();
    //    this.hasEarlyAck = other.hasEarlyAck();
    //    this.hasEnableAsyncConflation = other.hasEnableAsyncConflation();
    //    this.hasEnableSubscriptionConflation = other.hasEnableSubscriptionConflation();
    //    this.hasEnableGateway = other.hasEnableGateway();
    //    this.hasEntryIdleTimeout = other.hasEntryIdleTimeout();
    //    this.hasEntryTimeToLive = other.hasEntryTimeToLive();
    //    this.hasEvictionAttributes = other.hasEvictionAttributes();
    //    this.hasIgnoreJTA = other.hasIgnoreJTA();
    //    this.hasIndexMaintenanceSynchronous = other.hasIndexMaintenanceSynchronous();
    //    this.hasInitialCapacity = other.hasInitialCapacity();
    //    this.hasIsLockGrantor = other.hasIsLockGrantor();
    //    this.hasKeyConstraint = other.hasKeyConstraint();
    //    this.hasLoadFactor = other.hasLoadFactor();
    //    this.hasMembershipAttributes = other.hasMembershipAttributes();
    //    this.hasMulticastEnabled = other.hasMulticastEnabled();
    //    this.hasPartitionAttributes = other.hasPartitionAttributes();
    //    this.hasPublisher = other.hasPublisher();
    //    this.hasRegionIdleTimeout = other.hasRegionIdleTimeout();
    //    this.hasRegionTimeToLive = other.hasRegionTimeToLive();
    //    this.hasScope = other.hasScope();
    //    this.hasStatisticsEnabled = other.hasStatisticsEnabled();
    //    this.hasSubscriptionAttributes = other.hasSubscriptionAttributes();
    //    this.hasValueConstraint = other.hasValueConstraint();
  }
Example #15
0
 public static void isTrue(boolean b, String message) {
   com.gemstone.gemfire.internal.Assert.assertTrue(b, message);
 }
 public DistributedSystemConfig getConfig() {
   checkForRmiConnection();
   Assert.assertTrue(this.objectName != null);
   return new JMXDistributedSystemConfig(this.mbs, this.objectName, this.agentName);
 }
  /** Creates a new <code>JXMDistributedSystem</code> with the given configuration. */
  public JMXAdminDistributedSystem(
      final String mcastAddress,
      final int mcastPort,
      final String locators,
      final String bindAddress,
      final String remoteCommand,
      MBeanServerConnection mbs,
      JMXConnector conn,
      ObjectName agentName) {

    this(
        new DistributedSystemConfig() {
          public String getMcastAddress() {
            return mcastAddress;
          }

          public void setMcastAddress(String mcastAddress) {
            throw new UnsupportedOperationException();
          }

          public int getMcastPort() {
            return mcastPort;
          }

          public void setMcastPort(int mcastPort) {
            throw new UnsupportedOperationException();
          }

          public void setEnableNetworkPartitionDetection(boolean newValue) {
            throw new UnsupportedOperationException();
          }

          public boolean getEnableNetworkPartitionDetection() {
            throw new UnsupportedOperationException();
          }

          public int getMemberTimeout() {
            throw new UnsupportedOperationException();
          }

          public void setMemberTimeout(int value) {
            throw new UnsupportedOperationException();
          }

          public boolean getDisableAutoReconnect() {
            throw new UnsupportedOperationException();
          }

          public void setDisableAutoReconnect(boolean value) {
            throw new UnsupportedOperationException();
          }
          //        public int getMcastTtl() {
          //          throw new UnsupportedOperationException();
          //        }
          //        public void setMcastTtl(int v) {
          //          throw new UnsupportedOperationException();
          //        }
          //        public int getSocketLeaseTime() {
          //          throw new UnsupportedOperationException();
          //        }
          //        public void setSocketLeaseTime(int v) {
          //          throw new UnsupportedOperationException();
          //        }
          //        public int getSocketBufferSize() {
          //          throw new UnsupportedOperationException();
          //        }
          //        public void setSocketBufferSize(int v) {
          //          throw new UnsupportedOperationException();
          //        }
          //        public boolean getConserveSockets() {
          //          throw new UnsupportedOperationException();
          //        }
          //        public void setConserveSockets(boolean v) {
          //          throw new UnsupportedOperationException();
          //        }
          public String getLocators() {
            return locators;
          }

          public void setBindAddress(String bindAddress) {
            throw new UnsupportedOperationException();
          }

          public String getBindAddress() {
            return bindAddress;
          }

          public void setServerBindAddress(String bindAddress) {
            throw new UnsupportedOperationException();
          }

          public String getServerBindAddress() {
            throw new UnsupportedOperationException();
          }

          public void setLocators(String locators) {
            throw new UnsupportedOperationException();
          }

          public String getRemoteCommand() {
            return remoteCommand;
          }

          public void setRemoteCommand(String cmd) {
            throw new UnsupportedOperationException();
          }

          public CacheServerConfig[] getCacheServerConfigs() {
            throw new UnsupportedOperationException();
          }

          public CacheServerConfig createCacheServerConfig() {
            throw new UnsupportedOperationException();
          }

          public void removeCacheServerConfig(CacheServerConfig managerConfig) {
            throw new UnsupportedOperationException();
          }

          public CacheVmConfig[] getCacheVmConfigs() {
            throw new UnsupportedOperationException();
          }

          public CacheVmConfig createCacheVmConfig() {
            throw new UnsupportedOperationException();
          }

          public void removeCacheVmConfig(CacheVmConfig managerConfig) {
            throw new UnsupportedOperationException();
          }

          public DistributionLocatorConfig[] getDistributionLocatorConfigs() {
            throw new UnsupportedOperationException();
          }

          public DistributionLocatorConfig createDistributionLocatorConfig() {
            throw new UnsupportedOperationException();
          }

          public void removeDistributionLocatorConfig(DistributionLocatorConfig managerConfig) {
            throw new UnsupportedOperationException();
          }

          public void addListener(ConfigListener listener) {
            throw new UnsupportedOperationException();
          }

          public void removeListener(ConfigListener listener) {
            throw new UnsupportedOperationException();
          }

          public boolean isSSLEnabled() {
            return DistributionConfig.DEFAULT_SSL_ENABLED;
          }

          public void setSSLEnabled(boolean enabled) {
            throw new UnsupportedOperationException();
          }

          public String getSSLProtocols() {
            return DistributionConfig.DEFAULT_SSL_PROTOCOLS;
          }

          public void setSSLProtocols(String protocols) {
            throw new UnsupportedOperationException();
          }

          public String getSSLCiphers() {
            return DistributionConfig.DEFAULT_SSL_CIPHERS;
          }

          public void setSSLCiphers(String ciphers) {
            throw new UnsupportedOperationException();
          }

          public boolean isSSLAuthenticationRequired() {
            return DistributionConfig.DEFAULT_SSL_REQUIRE_AUTHENTICATION;
          }

          public void setSSLAuthenticationRequired(boolean authRequired) {
            throw new UnsupportedOperationException();
          }

          public Properties getSSLProperties() {
            return new Properties();
          }

          public void setSSLProperties(Properties sslProperties) {
            throw new UnsupportedOperationException();
          }
          //        public DistributionLocator[] getDistributionLocators() {
          //          throw new UnsupportedOperationException();
          //        }
          //        public void setDistributionLocators(DistributionLocator[] locs) {
          //          throw new UnsupportedOperationException();
          //        }
          public String getEntityConfigXMLFile() {
            throw new UnsupportedOperationException();
          }

          public void setEntityConfigXMLFile(String xmlFile) {
            throw new UnsupportedOperationException();
          }

          public String getSystemId() {
            throw new UnsupportedOperationException();
          }

          public void setSystemId(String systemId) {
            throw new UnsupportedOperationException();
          }

          public String getSystemName() {
            throw new UnsupportedOperationException();
          }

          public void setSystemName(String systemName) {
            throw new UnsupportedOperationException();
          }

          public void validate() {}

          public void addSSLProperty(String key, String value) {
            throw new UnsupportedOperationException();
          }

          public void removeSSLProperty(String key) {
            throw new UnsupportedOperationException();
          }

          public String getLogFile() {
            throw new UnsupportedOperationException();
          }

          public void setLogFile(String logFile) {
            throw new UnsupportedOperationException();
          }

          public String getLogLevel() {
            throw new UnsupportedOperationException();
          }

          public void setLogLevel(String logLevel) {
            throw new UnsupportedOperationException();
          }

          public int getLogDiskSpaceLimit() {
            throw new UnsupportedOperationException();
          }

          public void setLogDiskSpaceLimit(int limit) {
            throw new UnsupportedOperationException();
          }

          public int getLogFileSizeLimit() {
            throw new UnsupportedOperationException();
          }

          public void setLogFileSizeLimit(int limit) {
            throw new UnsupportedOperationException();
          }

          public boolean getDisableTcp() {
            throw new UnsupportedOperationException();
          }

          public void setDisableTcp(boolean flag) {
            throw new UnsupportedOperationException();
          }

          public int getAckWaitThreshold() {
            throw new UnsupportedOperationException();
          }

          public void setAckWaitThreshold(int seconds) {
            throw new UnsupportedOperationException();
          }

          public int getAckSevereAlertThreshold() {
            throw new UnsupportedOperationException();
          }

          public void setAckSevereAlertThreshold(int seconds) {
            throw new UnsupportedOperationException();
          }

          public int getRefreshInterval() {
            throw new UnsupportedOperationException();
          }

          public void setRefreshInterval(int seconds) {
            throw new UnsupportedOperationException();
          }

          public String getMembershipPortRange() {
            throw new UnsupportedOperationException();
          }

          public void setMembershipPortRange(String membershipPortRange) {
            throw new UnsupportedOperationException();
          }

          public Object clone() {
            throw new UnsupportedOperationException();
          }

          public int getTcpPort() {
            throw new UnsupportedOperationException();
          }

          public void setTcpPort(int port) {
            throw new UnsupportedOperationException();
          }
        },
        mbs,
        conn,
        agentName);
    Assert.assertTrue(agentName != null);
  }
  /** Creates a <code>BridgeServerResponse</code> in response to the given request. */
  static BridgeServerResponse create(DistributionManager dm, BridgeServerRequest request) {
    BridgeServerResponse m = new BridgeServerResponse();
    m.setRecipient(request.getSender());

    try {
      GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getInstanceCloseOk(dm.getSystem());

      if (request.getCacheId() != System.identityHashCode(cache)) {
        m.bridgeInfo = null;

      } else {
        int operation = request.getOperation();
        switch (operation) {
          case BridgeServerRequest.ADD_OPERATION:
            {
              BridgeServerImpl bridge = (BridgeServerImpl) cache.addBridgeServer();
              m.bridgeInfo = new RemoteBridgeServer(bridge);
              break;
            }

          case BridgeServerRequest.INFO_OPERATION:
            {
              int id = request.getBridgeId();
              // Note that since this is only an informational request
              // it is not necessary to synchronize on allBridgeServersLock
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == id) {
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          case BridgeServerRequest.START_OPERATION:
            {
              RemoteBridgeServer config = request.getBridgeInfo();
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == config.getId()) {
                  bridge.configureFrom(config);
                  bridge.start();
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          case BridgeServerRequest.STOP_OPERATION:
            {
              RemoteBridgeServer config = request.getBridgeInfo();
              for (Iterator iter = cache.getBridgeServers().iterator(); iter.hasNext(); ) {
                BridgeServerImpl bridge = (BridgeServerImpl) iter.next();
                if (System.identityHashCode(bridge) == config.getId()) {
                  bridge.stop();
                  m.bridgeInfo = new RemoteBridgeServer(bridge);
                  break;

                } else {
                  m.bridgeInfo = null;
                }
              }
              break;
            }

          default:
            Assert.assertTrue(false, "Unknown bridge server operation: " + operation);
        }
      }

    } catch (CancelException ex) {
      m.bridgeInfo = null;

    } catch (Exception ex) {
      m.exception = ex;
      m.bridgeInfo = null;
    }
    return m;
  }
Example #19
0
 public static void notNull(Object object, String message) {
   com.gemstone.gemfire.internal.Assert.assertTrue(object != null, message);
 }
 /**
  * @param count the number of times {@link #countDown} must be invoked before threads can pass
  *     through {@link #await()}
  * @throws IllegalArgumentException if {@code count} is negative
  */
 public StoppableCountDownLatch(CancelCriterion stopper, int count) {
   Assert.assertTrue(stopper != null);
   this.latch = new CountDownLatch(count);
   this.stopper = stopper;
 }