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.cloudfoundry;
import org.apache.brooklyn.location.cloudfoundry.CloudFoundryPaasLocation;
import com.google.common.base.Functions;
import com.google.common.collect.Iterables;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.entity.drivers.DriverDependentEntity;
import org.apache.brooklyn.api.entity.drivers.EntityDriverManager;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.mgmt.Task;
import org.apache.brooklyn.api.sensor.EnricherSpec;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
import org.apache.brooklyn.core.enricher.AbstractEnricher;
import org.apache.brooklyn.core.entity.AbstractEntity;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
import org.apache.brooklyn.feed.function.FunctionFeed;
import org.apache.brooklyn.feed.function.FunctionPollConfig;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.config.ConfigBag;
import org.apache.brooklyn.util.core.task.DynamicTasks;
import org.apache.brooklyn.util.core.task.Tasks;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.time.CountdownTimer;
import org.apache.brooklyn.util.time.Duration;
import org.apache.brooklyn.util.time.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
public abstract class CloudFoundryEntityImpl extends AbstractEntity implements CloudFoundryEntity,
DriverDependentEntity {
private static final Logger log = LoggerFactory.getLogger(CloudFoundryEntityImpl.class);
private transient PaasEntityDriver driver;
/**
* @see #connectServiceUpIsRunning()
*/
private volatile FunctionFeed serviceProcessIsRunning;
protected boolean connectedSensors = false;
public CloudFoundryEntityImpl() {
super(MutableMap.of(), null);
}
public CloudFoundryEntityImpl(Entity parent) {
this(MutableMap.of(), parent);
}
public CloudFoundryEntityImpl(Map properties) {
this(properties, null);
}
public CloudFoundryEntityImpl(Map properties, Entity parent) {
super(properties, parent);
}
@Override
public abstract Class getDriverInterface();
@Override
public PaasEntityDriver getDriver() {
return driver;
}
protected CloudFoundryPaasLocation getLocationOrNull() {
return Iterables.get(Iterables
.filter(getLocations(), CloudFoundryPaasLocation.class), 0, null);
}
@Override
public void init() {
super.init();
}
@Override
protected void initEnrichers() {
super.initEnrichers();
ServiceStateLogic.ServiceNotUpLogic
.updateNotUpIndicator(this, SERVICE_PROCESS_IS_RUNNING,
"No information yet on whether this service is running");
// add an indicator above so that if is_running comes through, the map is cleared and
// an update is guaranteed
addEnricher(EnricherSpec.create(UpdatingNotUpFromServiceProcessIsRunning.class)
.uniqueTag("service-process-is-running-updating-not-up"));
}
/**
* This sub-class was copied directly from {@link brooklyn.entity.basic.SoftwareProcessImpl}
* subscribes to SERVICE_PROCESS_IS_RUNNING and SERVICE_UP; the latter has no effect if
* the former is set, but to support entities which set SERVICE_UP directly we want
* to make sure that the absence of SERVICE_PROCESS_IS_RUNNING does not trigger any
* not-up indicators
*/
protected static class UpdatingNotUpFromServiceProcessIsRunning extends AbstractEnricher
implements SensorEventListener