Search in sources :

Example 1 with Repository

use of org.apache.geode.tools.pulse.internal.data.Repository in project geode by apache.

the class PulseControllerJUnitTest method setup.

@Before
public void setup() throws Exception {
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    cluster = Mockito.spy(Cluster.class);
    Cluster.Region region = new Cluster.Region();
    region.setName(REGION_NAME);
    region.setFullPath(REGION_PATH);
    region.setRegionType(REGION_TYPE);
    region.setMemberCount(1);
    region.setMemberName(new ArrayList<String>() {

        {
            add(MEMBER_NAME);
        }
    });
    region.setPutsRate(12.31D);
    region.setGetsRate(27.99D);
    Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
    regionOnMember.setRegionFullPath(REGION_PATH);
    regionOnMember.setMemberName(MEMBER_NAME);
    region.setRegionOnMembers(new ArrayList<Cluster.RegionOnMember>() {

        {
            add(regionOnMember);
        }
    });
    cluster.addClusterRegion(REGION_PATH, region);
    Cluster.Member member = new Cluster.Member();
    member.setId(MEMBER_ID);
    member.setName(MEMBER_NAME);
    member.setUptime(1L);
    member.setHost(PHYSICAL_HOST_NAME);
    member.setGemfireVersion(GEMFIRE_VERSION);
    member.setCpuUsage(55.77123D);
    member.setMemberRegions(new HashMap<String, Cluster.Region>() {

        {
            put(REGION_NAME, region);
        }
    });
    Cluster.AsyncEventQueue aeq = new Cluster.AsyncEventQueue();
    aeq.setAsyncEventListener(AEQ_LISTENER);
    member.setAsyncEventQueueList(new ArrayList() {

        {
            add(aeq);
        }
    });
    Cluster.Client client = new Cluster.Client();
    client.setId("100");
    client.setName(CLIENT_NAME);
    client.setUptime(1L);
    member.setMemberClientsHMap(new HashMap<String, Cluster.Client>() {

        {
            put(CLIENT_NAME, client);
        }
    });
    cluster.setMembersHMap(new HashMap() {

        {
            put(MEMBER_NAME, member);
        }
    });
    cluster.setPhysicalToMember(new HashMap() {

        {
            put(PHYSICAL_HOST_NAME, new ArrayList() {

                {
                    add(member);
                }
            });
        }
    });
    cluster.setServerName(CLUSTER_NAME);
    cluster.setMemoryUsageTrend(new CircularFifoBuffer() {

        {
            add(1);
            add(2);
            add(3);
        }
    });
    cluster.setWritePerSecTrend(new CircularFifoBuffer() {

        {
            add(1.29);
            add(2.3);
            add(3.0);
        }
    });
    cluster.setThroughoutReadsTrend(new CircularFifoBuffer() {

        {
            add(1);
            add(2);
            add(3);
        }
    });
    cluster.setThroughoutWritesTrend(new CircularFifoBuffer() {

        {
            add(4);
            add(5);
            add(6);
        }
    });
    Repository repo = Mockito.spy(Repository.class);
    // Set up a partial mock for some static methods
    spy(Repository.class);
    when(Repository.class, "get").thenReturn(repo);
    doReturn(cluster).when(repo).getCluster();
    PulseConfig config = new PulseConfig();
    File tempQueryLog = tempFolder.newFile("query_history.log");
    config.setQueryHistoryFileName(tempQueryLog.toString());
    doReturn(config).when(repo).getPulseConfig();
    PulseController.pulseVersion.setPulseVersion("not empty");
    PulseController.pulseVersion.setPulseBuildId("not empty");
    PulseController.pulseVersion.setPulseBuildDate("not empty");
    PulseController.pulseVersion.setPulseSourceDate("not empty");
    PulseController.pulseVersion.setPulseSourceRevision("not empty");
    PulseController.pulseVersion.setPulseSourceRepository("not empty");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) Matchers.anyString(org.mockito.Matchers.anyString) CircularFifoBuffer(org.apache.commons.collections.buffer.CircularFifoBuffer) Repository(org.apache.geode.tools.pulse.internal.data.Repository) PulseConfig(org.apache.geode.tools.pulse.internal.data.PulseConfig) File(java.io.File) Before(org.junit.Before)

Example 2 with Repository

use of org.apache.geode.tools.pulse.internal.data.Repository in project geode by apache.

the class ClusterMembersRGraphService method execute.

public ObjectNode execute(final HttpServletRequest request) throws Exception {
    // Reference to repository
    Repository repository = Repository.get();
    // get cluster object
    Cluster cluster = repository.getCluster();
    // json object to be sent as response
    ObjectNode responseJSON = mapper.createObjectNode();
    // cluster's Members
    responseJSON.put(this.CLUSTER, getPhysicalServerJson(cluster, repository.getHost(), repository.getPort()));
    responseJSON.put(this.MEMBER_COUNT, cluster.getMemberCount());
    // Send json response
    return responseJSON;
}
Also used : Repository(org.apache.geode.tools.pulse.internal.data.Repository) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster)

Example 3 with Repository

use of org.apache.geode.tools.pulse.internal.data.Repository in project geode by apache.

the class PulseAppListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent event) {
    logger.info(resourceBundle.getString("LOG_MSG_CONTEXT_INITIALIZED"));
    // Load Pulse Properties
    pulseProperties = loadProperties(PulseConstants.PULSE_PROPERTIES_FILE);
    // Load Pulse version details
    loadPulseVersionDetails();
    // load pulse security properties
    pulseSecurityProperties = loadProperties(PulseConstants.PULSE_SECURITY_PROPERTIES_FILE);
    // Reference to repository
    Repository repository = Repository.get();
    logger.info(resourceBundle.getString("LOG_MSG_CHECK_APP_RUNNING_MODE"));
    boolean sysIsEmbedded = Boolean.getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED);
    if (sysIsEmbedded) {
        // jmx connection parameters
        logger.info(resourceBundle.getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE"));
        repository.setJmxUseLocator(false);
        repository.setHost(PulseConstants.GEMFIRE_DEFAULT_HOST);
        repository.setPort(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, PulseConstants.GEMFIRE_DEFAULT_PORT));
        // SSL, all the other system properties are already set in the embedded VM
        repository.setUseSSLManager(Boolean.valueOf(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER)));
        repository.setUseSSLLocator(Boolean.valueOf(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR)));
    } else {
        // jmx connection parameters
        logger.info(resourceBundle.getString("LOG_MSG_APP_RUNNING_NONEMBEDDED_MODE"));
        repository.setJmxUseLocator(Boolean.valueOf(pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_USELOCATOR)));
        repository.setHost(pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_HOST, PulseConstants.GEMFIRE_DEFAULT_HOST));
        repository.setPort(pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_PORT, PulseConstants.GEMFIRE_DEFAULT_PORT));
        // SSL
        repository.setUseSSLManager(Boolean.valueOf(pulseProperties.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, "false")));
        repository.setUseSSLLocator(Boolean.valueOf(pulseProperties.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, "false")));
        // set the ssl related properties found in pulsesecurity.properties
        if (!pulseSecurityProperties.isEmpty()) {
            Set entrySet = pulseSecurityProperties.entrySet();
            for (Iterator it = entrySet.iterator(); it.hasNext(); ) {
                Entry<String, String> entry = (Entry<String, String>) it.next();
                String key = entry.getKey();
                if (key.startsWith("javax.net.ssl.")) {
                    String val = entry.getValue();
                    System.setProperty(key, val);
                }
            }
        }
    }
}
Also used : Repository(org.apache.geode.tools.pulse.internal.data.Repository) Entry(java.util.Map.Entry) Set(java.util.Set) Iterator(java.util.Iterator)

Aggregations

Repository (org.apache.geode.tools.pulse.internal.data.Repository)3 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 CircularFifoBuffer (org.apache.commons.collections.buffer.CircularFifoBuffer)1 PulseConfig (org.apache.geode.tools.pulse.internal.data.PulseConfig)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1