Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.
*/
package org.apache.brooklyn.entity.nosql.mongodb;
import java.net.UnknownHostException;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
import org.apache.brooklyn.core.config.render.RendererHints;
import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
import org.apache.brooklyn.feed.function.FunctionFeed;
import org.apache.brooklyn.feed.function.FunctionPollConfig;
import org.bson.BasicBSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Functions;
import com.google.common.base.MoreObjects;
import com.google.common.net.HostAndPort;
public class MongoDBServerImpl extends SoftwareProcessImpl implements MongoDBServer {
private static final Logger LOG = LoggerFactory.getLogger(MongoDBServerImpl.class);
static {
RendererHints.register(HTTP_INTERFACE_URL, RendererHints.namedActionWithUrl());
}
private FunctionFeed serviceStats;
private FunctionFeed replicaSetStats;
private MongoDBClientSupport client;
public MongoDBServerImpl() {
}
@Override
public Class> getDriverInterface() {
return MongoDBDriver.class;
}
@Override
protected void connectSensors() {
super.connectSensors();
connectServiceUpIsRunning();
int port = sensors().get(MongoDBServer.PORT);
HostAndPort accessibleAddress = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, port);
sensors().set(MONGO_SERVER_ENDPOINT, String.format("%s:%d",
accessibleAddress.getHostText(), accessibleAddress.getPort()));
int httpConsolePort = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, sensors().get(HTTP_PORT)).getPort();
sensors().set(HTTP_INTERFACE_URL, String.format("http://%s:%d",
accessibleAddress.getHostText(), httpConsolePort));
if (clientAccessEnabled()) {
try {
client = MongoDBClientSupport.forServer(this);
} catch (UnknownHostException e) {
LOG.warn("Unable to create client connection to {}, not connecting sensors: {} ", this, e.getMessage());
return;
}
serviceStats = FunctionFeed.builder()
.entity(this)
.poll(new FunctionPollConfig