String getMBeanObjectName(final ServerId serverId) { String name = format("org.mongodb.driver:type=ConnectionPool,clusterId=%s,host=%s,port=%s", ensureValidValue(serverId.getClusterId().getValue()), ensureValidValue(serverId.getAddress().getHost()), serverId.getAddress().getPort()); if (serverId.getClusterId().getDescription() != null) { name = format("%s,description=%s", name, ensureValidValue(serverId.getClusterId().getDescription())); } return name; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ServerId serverId = (ServerId) o; if (!address.equals(serverId.address)) { return false; } if (!clusterId.equals(serverId.clusterId)) { return false; } return true; }
@Override public int hashCode() { int result = clusterId.hashCode(); result = 31 * result + address.hashCode(); return result; }
private synchronized void notifyWaitQueueHandler(final ServerSelectionRequest request) { if (isClosed) { return; } if (waitQueueSize.incrementAndGet() > settings.getMaxWaitQueueSize()) { waitQueueSize.decrementAndGet(); request.onResult(null, createWaitQueueFullException()); } else { waitQueue.add(request); if (waitQueueHandler == null) { waitQueueHandler = new Thread(new WaitQueueHandler(), "cluster-" + clusterId.getValue()); waitQueueHandler.setDaemon(true); waitQueueHandler.start(); } } }
final List<MongoCompressor> compressorList) { ClusterId clusterId = new ClusterId(clusterSettings.getDescription());
private synchronized void notifyWaitQueueHandler(final ServerSelectionRequest request) { if (isClosed) { return; } if (waitQueueSize.incrementAndGet() > settings.getMaxWaitQueueSize()) { waitQueueSize.decrementAndGet(); request.onResult(null, createWaitQueueFullException()); } else { waitQueue.add(request); if (waitQueueHandler == null) { waitQueueHandler = new Thread(new WaitQueueHandler(), "cluster-" + clusterId.getValue()); waitQueueHandler.setDaemon(true); waitQueueHandler.start(); } } }
EmbeddedInternalConnection(final Pointer instancePointer, final CommandListener commandListener, final BsonDocument clientMetadataDocument) { this.clientStatusPointer = MongoDBCAPIHelper.createStatusPointer(); this.clientPointer = MongoDBCAPIHelper.create_client(instancePointer, clientStatusPointer); this.wrapped = new InternalStreamConnection(new ServerId(new ClusterId(), new ServerAddress()), new StreamFactory() { @Override public Stream create(final ServerAddress serverAddress) { return new EmbeddedInternalStream(); } }, Collections.<MongoCompressor>emptyList(), commandListener, new InternalStreamConnectionInitializer(Collections.<Authenticator>emptyList(), clientMetadataDocument, Collections.<MongoCompressor>emptyList())); }
String getMBeanObjectName(final ServerId serverId) { String name = format("org.mongodb.driver:type=ConnectionPool,clusterId=%s,host=%s,port=%s", ensureValidValue(serverId.getClusterId().getValue()), ensureValidValue(serverId.getAddress().getHost()), serverId.getAddress().getPort()); if (serverId.getClusterId().getDescription() != null) { name = format("%s,description=%s", name, ensureValidValue(serverId.getClusterId().getDescription())); } return name; }
private PoolMetric(final ServerId serverId) { final String clusterId = serverId.getClusterId().getValue(); poolSizeGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + POOL_SIZE) .tag(CLUSTER_ID_TAG, clusterId); poolSizeGauge.set(0L); checkOutCountGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + CHECKED_OUT_COUNT) .tag(CLUSTER_ID_TAG, clusterId); checkOutCountGauge.set(0L); waitQueueGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + WAIT_QUEUE_SIZE) .tag(CLUSTER_ID_TAG, clusterId); waitQueueGauge.set(0L); }
final List<MongoCompressor> compressorList) { ClusterId clusterId = new ClusterId(clusterSettings.getDescription());
@Override public int hashCode() { int result = clusterId.hashCode(); result = 31 * result + address.hashCode(); return result; }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ServerId serverId = (ServerId) o; if (!address.equals(serverId.address)) { return false; } if (!clusterId.equals(serverId.clusterId)) { return false; } return true; }
private PoolMetric(final ServerId serverId) { final String clusterId = serverId.getClusterId().getValue(); poolSizeGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + POOL_SIZE) .tag(CLUSTER_ID_TAG, clusterId); poolSizeGauge.set(0L); checkOutCountGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + CHECKED_OUT_COUNT) .tag(CLUSTER_ID_TAG, clusterId); checkOutCountGauge.set(0L); waitQueueGauge = DittoMetrics.gauge(metricName + POOL_PREFIX + WAIT_QUEUE_SIZE) .tag(CLUSTER_ID_TAG, clusterId); waitQueueGauge.set(0L); }