Package io.fabric8.zookeeper.spring

Examples of io.fabric8.zookeeper.spring.ZKServerFactoryBean


public class ServiceMixNodeProvider implements NodeProvider {

  @Override
  public void provide(final Root root) {
    if (root.containsDomain("org.apache.servicemix")) {
      ServiceMixFacade facade = new JmxTemplateServiceMixFacade(new JmxPluginJmxTemplate(root.getConnection()));
      ServiceMixNode camel = new ServiceMixNode(root, facade);
      root.addChild(camel);
    }
  }
View Full Code Here


    if( parentElement instanceof IConnectionWrapper ) {
      IConnectionWrapper w = (IConnectionWrapper)parentElement;
      Root r = w.getRoot();
      if( r != null ) {
        if (r.containsDomain("org.apache.servicemix")) {
          ServiceMixFacade facade = new JmxTemplateServiceMixFacade(new JmxPluginJmxTemplate(r.getConnection()));
          ServiceMixNode smx = new ServiceMixNode(r, facade);
          return new Object[]{smx};
        }
      }
    } else if (parentElement instanceof NodeSupport) {
View Full Code Here

public class ServiceMixNodeProvider implements NodeProvider {

  @Override
  public void provide(final Root root) {
    if (root.containsDomain("org.apache.servicemix")) {
      ServiceMixFacade facade = new JmxTemplateServiceMixFacade(new JmxPluginJmxTemplate(root.getConnection()));
      ServiceMixNode camel = new ServiceMixNode(root, facade);
      root.addChild(camel);
    }
  }
View Full Code Here

    @Override
    public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
        Kubernetes kubernetes = getKubernetes();
        PodListSchema pods = kubernetes.getPods();
        KubernetesHelper.removeEmptyPods(pods);
        TablePrinter table = podsAsTable(pods);
        return tableResults(table);
    }
View Full Code Here

        TablePrinter table = podsAsTable(pods);
        return tableResults(table);
    }

    protected TablePrinter podsAsTable(PodListSchema pods) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "image(s)", "host", "labels", "status");
        List<PodSchema> items = pods.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<PodSchema> filter = KubernetesHelper.createPodFilter(filterText.getValue());
        for (PodSchema item : items) {
            if (filter.matches(item)) {
                String id = item.getId();
                CurrentState currentState = item.getCurrentState();
                String status = "";
                String host = "";
                if (currentState != null) {
                    status = currentState.getStatus();
                    host = currentState.getHost();
                }
                Map<String, String> labelMap = item.getLabels();
                String labels = KubernetesHelper.toLabelsString(labelMap);
                DesiredState desiredState = item.getDesiredState();
                if (desiredState != null) {
                    Manifest manifest = desiredState.getManifest();
                    if (manifest != null) {
                        List<ManifestContainer> containers = manifest.getContainers();
                        for (ManifestContainer container : containers) {
                            String image = container.getImage();
                            table.row(id, image, host, labels, status);

                            id = "";
                            host = "";
                            status = "";
                            labels = "";
View Full Code Here

        printReplicationControllers(replicationControllers, System.out);
        return null;
    }

    private void printReplicationControllers(ReplicationControllerListSchema replicationControllers, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "labels", "replicas", "replica selector");
        List<ReplicationControllerSchema> items = replicationControllers.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<ReplicationControllerSchema> filter = KubernetesHelper.createReplicationControllerFilter(filterText.getValue());
        for (ReplicationControllerSchema item : items) {
            if (filter.matches(item)) {
                String id = item.getId();
                String labels = KubernetesHelper.toLabelsString(item.getLabels());
                Integer replicas = null;
                ControllerDesiredState desiredState = item.getDesiredState();
                ControllerCurrentState currentState = item.getCurrentState();
                String selector = null;
                if (desiredState != null) {
                    selector = KubernetesHelper.toLabelsString(desiredState.getReplicaSelector());
                }
                if (currentState != null) {
                    replicas = currentState.getReplicas();
                }
                table.row(id, labels, toPositiveNonZeroText(replicas), selector);
            }
        }
        table.print();
    }
View Full Code Here

        printServices(services, System.out);
        return null;
    }

    private void printServices(ServiceListSchema services, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "labels", "selector", "port");
        List<ServiceSchema> items = services.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<ServiceSchema> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
        for (ServiceSchema item : items) {
            if (filter.matches(item)) {
                String labels = KubernetesHelper.toLabelsString(item.getLabels());
                String selector = KubernetesHelper.toLabelsString(item.getSelector());
                table.row(item.getId(), labels, selector, KubernetesHelper.toPositiveNonZeroText(item.getPort()));
            }
        }
        table.print();
    }
View Full Code Here

        basedir = System.getProperty("basedir", ".");
        String karafRoot = basedir + "/target/karaf";
        System.setProperty("karaf.root", karafRoot);
        System.setProperty("karaf.data", karafRoot + "/data");

        sfb = new ZKServerFactoryBean();
        delete(sfb.getDataDir());
        delete(sfb.getDataLogDir());
        sfb.setPort(9123);
        sfb.afterPropertiesSet();
View Full Code Here

public class ManagerTest {

    @Test
    public void testManager() throws Exception {

        ZKServerFactoryBean zkServerFactoryBean = null;

        try {

            int zooKeeperPort = getFreePort();
            int serverPort = getFreePort();

            zkServerFactoryBean = new ZKServerFactoryBean();
            zkServerFactoryBean.setPurge(true);
            zkServerFactoryBean.setClientPortAddress(new InetSocketAddress("localhost", zooKeeperPort));
            zkServerFactoryBean.afterPropertiesSet();

            CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
                    .connectString("localhost:" + zooKeeperPort)
                    .retryPolicy(new RetryOneTime(1000))
                    .connectionTimeoutMs(60000);

            CuratorFramework curator = builder.build();
            curator.start();
            curator.getZookeeperClient().blockUntilConnectedOrTimedOut();

            BundleContext bundleContext = createMock(BundleContext.class);
            ServiceRegistration registration = createMock(ServiceRegistration.class);
            Manager manager = new Manager(bundleContext, curator, "tcp://localhost:" + serverPort, "localhost", TimeUnit.MINUTES.toMillis(5));

            bundleContext.addServiceListener(manager, "(service.exported.interfaces=*)");
            expect(bundleContext.getProperty("org.osgi.framework.uuid")).andReturn("the-framework-uuid");
            expect(bundleContext.registerService(
                    EasyMock.<String[]>anyObject(),
                    same(manager),
                    EasyMock.<Dictionary>same(null))).andReturn(registration);
            expect(bundleContext.getServiceReferences((String) null, "(service.exported.interfaces=*)")).andReturn(null);

            replay(bundleContext, registration);

            manager.init();

            verify(bundleContext, registration);

            reset(bundleContext, registration);

            BundleContext expBundleContext = createMock(BundleContext.class);
            Bundle expBundle = createMock(Bundle.class);
            ServiceReference reference = createMock(ServiceReference.class);
            final Properties props = new Properties();
            props.put(Constants.OBJECTCLASS, new String[]{ConfigurationAdmin.class.getName()});
            expect(reference.getProperty(EasyMock.<String>anyObject())).andAnswer(new IAnswer<Object>() {
                public Object answer() throws Throwable {
                    return props.get(EasyMock.getCurrentArguments()[0]);
                }
            }).anyTimes();
            expect(reference.getPropertyKeys()).andReturn(props.keySet().toArray(new String[0]));
            expect(reference.getBundle()).andReturn(expBundle).anyTimes();
            expect(expBundle.getBundleContext()).andReturn(expBundleContext).anyTimes();
            expect(expBundle.getState()).andReturn(Bundle.ACTIVE).anyTimes();

            replay(bundleContext, registration, reference, expBundleContext, expBundle);

            manager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, reference));
            Thread.sleep(1000);

            verify(bundleContext, registration, reference, expBundleContext, expBundle);

        }
        finally {
            try {
                zkServerFactoryBean.destroy();
            } catch (Throwable t) { }
        }
    }
View Full Code Here

    private String basedir;
    private RuntimeProperties runtimeProperties;

    @Before
    public void setUp() throws Exception {
        sfb = new ZKServerFactoryBean();
        delete(sfb.getDataDir());
        delete(sfb.getDataLogDir());
        sfb.afterPropertiesSet();
        runtimeProperties = EasyMock.createMock(RuntimeProperties.class);
        EasyMock.expect(runtimeProperties.getRuntimeIdentity()).andReturn("root").anyTimes();
View Full Code Here

TOP

Related Classes of io.fabric8.zookeeper.spring.ZKServerFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.