Examples of DefaultTransaction


Examples of com.dianping.cat.message.internal.DefaultTransaction

    tree.setDomain("cat");
    tree.setHostName("group001");
    tree.setIpAddress("192.168.1.1");

    DefaultTransaction t = new DefaultTransaction("A", "n" + i % 2, null);
    DefaultTransaction t2 = new DefaultTransaction("A-1", "n" + i % 3, null);

    if (i % 2 == 0) {
      t2.setStatus("ERROR");
    } else {
      t2.setStatus(Message.SUCCESS);
    }

    t2.complete();
    t2.setDurationInMillis(i);

    t.addChild(t2);

    if (i % 2 == 0) {
      t.setStatus("ERROR");
    } else {
      t.setStatus(Message.SUCCESS);
    }

    t.complete();
    t.setDurationInMillis(i * 2);
    long timestamp = 1385467200000L;

    t.setTimestamp(timestamp + 1000);
    t2.setTimestamp(timestamp + 2000);
    tree.setMessage(t);
    tree.setMessageId("Cat-0a010680-384852-" + i);

    return tree;
  }
View Full Code Here

Examples of com.dianping.cat.message.internal.DefaultTransaction

    Assert.assertEquals(false, manager.isJobMachine());
    Assert.assertEquals(false, manager.isLocalMode());
    Assert.assertEquals(true, manager.isServerService("Service"));
    Assert.assertEquals(false, manager.validateDomain("All"));
   
    Transaction t = new DefaultTransaction("Service", "piegonService:heartTaskService:heartBeat", null);
    Assert.assertEquals(true, manager.discardTransaction(t));

    manager.initialize(null);

    Assert.assertEquals(true, manager.getServerConfig() != null);
View Full Code Here

Examples of com.dianping.cat.message.internal.DefaultTransaction

    tree.setMessageId("" + i);
    tree.setDomain(m_domain);
    tree.setHostName("group001");
    tree.setIpAddress("192.168.1.1");

    DefaultTransaction t;

    if (i % 2 == 0) {
      t = new DefaultTransaction("PigeonCall", "Cat-Test-Call", null);
      DefaultEvent event = new DefaultEvent("PigeonCall.server", "192.168.1.0:3000:class:method1");

      event.setTimestamp(m_timestamp + 5 * 60 * 1000);
      event.setStatus(Message.SUCCESS);
      t.addChild(event);

      DefaultEvent eventApp = new DefaultEvent("PigeonCall.app", "server");

      eventApp.setTimestamp(m_timestamp + 5 * 60 * 1000 + 100);
      eventApp.setStatus(Message.SUCCESS);
      t.addChild(eventApp);
    } else {
      t = new DefaultTransaction("PigeonService", "Cat-Test-Service", null);
      DefaultEvent event = new DefaultEvent("PigeonService.client", "192.168.1.2:3000:class:method2");

      event.setTimestamp(m_timestamp + 5 * 60 * 1000);
      event.setStatus(Message.SUCCESS);
      t.addChild(event);

      DefaultEvent eventApp = new DefaultEvent("PigeonService.app", "client");

      eventApp.setTimestamp(m_timestamp + 5 * 60 * 1000 + 100);
      eventApp.setStatus(Message.SUCCESS);
      t.addChild(eventApp);
    }

    t.complete();
    t.setDurationInMillis(i * 2);
    t.setTimestamp(m_timestamp + 1000);
    tree.setMessage(t);

    return tree;
  }
View Full Code Here

Examples of com.dianping.cat.message.internal.DefaultTransaction

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Other", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(true, info == null);
  }
View Full Code Here

Examples of com.dianping.cat.message.internal.DefaultTransaction

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Call", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "Unknown");

    Message message = new DefaultEvent("PigeonCall.server", "10.1.1.1", null);
    Message messageApp = new DefaultEvent("PigeonCall.app", "myDomain", null);
    t.addChild(message);
    t.addChild(messageApp);

    info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "10.1.1.1");
View Full Code Here

Examples of com.dianping.cat.message.internal.DefaultTransaction

    analyzer.setServerConfigManager(lookup(ServerConfigManager.class));
    analyzer.setIpConvertManager(new IpConvertManager());
    analyzer.setCrossAppSwitch(new CrossAppSwitch().setTurnOn(true));

    DefaultTransaction t = new DefaultTransaction("Service", "method1", null);
    MessageTree tree = buildMockMessageTree();
    CrossInfo info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "192.168.7.70");

    Message message = new DefaultEvent("PigeonService.client", "192.168.7.71", null);
    Message messageApp = new DefaultEvent("PigeonService.app", "myDomain", null);
    t.addChild(message);
    t.addChild(messageApp);

    info = analyzer.parseCorssTransaction(t, tree);

    Assert.assertEquals(info.getLocalAddress(), "192.168.0.1");
    Assert.assertEquals(info.getRemoteAddress(), "192.168.7.71");
View Full Code Here

Examples of org.geotools.data.DefaultTransaction

              }
            }
            else
              throw new Exception("Unknown export type.");

            Transaction transaction = new DefaultTransaction("create");

            String typeName = dataStore.getTypeNames()[0];
            SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);

            if (featureSource instanceof SimpleFeatureStore)
            {
                SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;

                featureStore.setTransaction(transaction);
              
                featureStore.addFeatures(collection);
                transaction.commit();

                transaction.close();
            }
            else
            {
              throw new Exception(typeName + " does not support read/write access");
            }
View Full Code Here

Examples of org.geotools.data.DefaultTransaction

    public void writeToShapefile( ShapefileDataStore dataStore, FeatureCollection<SimpleFeatureType, SimpleFeature> collection )
            throws IOException {
        String featureName = dataStore.getTypeNames()[0];
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource(featureName);

        Transaction transaction = new DefaultTransaction("create");
        try {
            FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
            featureStore.setTransaction(transaction);
            featureStore.addFeatures(collection);
            transaction.commit();
        } catch (Exception eek) {
            transaction.rollback();
            throw new IOException("The transaction could now be finished, an error orrcurred", eek);
        } finally {
            transaction.close();
        }
    }
View Full Code Here

Examples of org.geotools.data.DefaultTransaction

       
        monitor.beginTask(Messages.ReshapeOperation_task, 100 );

        List<Definition> transform = dialog.getTransform();
        TransformProcess process = new TransformProcess();
        DefaultTransaction transaction = new DefaultTransaction("Processing "+source.getName() ); //$NON-NLS-1$
        try {
            SimpleFeatureCollection collection = source.getFeatures();
            SimpleFeatureCollection output = process.executeList(collection, transform);

           
            final SimpleFeatureType featureType = output.getSchema();
           
            IGeoResource scratch = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource( featureType );
            final SimpleFeatureStore store = scratch.resolve(SimpleFeatureStore.class, SubMonitor.convert(monitor,Messages.ReshapeOperation_createTempSpaceTask, 10));
           
            store.setTransaction( transaction );
           
            ProgressListener progessListener = GeoToolsAdapters.progress( SubMonitor.convert(monitor,"processing "+source.getName(), 90));         //$NON-NLS-1$

            output.accepts(new FeatureVisitor(){
                boolean warning = true;
                public void visit( Feature rawFeature ) {
                    SimpleFeature feature = (SimpleFeature) rawFeature;
                    String fid = feature.getID();
                   
                    try {
                        store.addFeatures(DataUtilities.collection(feature));
                    } catch (Throwable t) {
                        if (warning) {
                            System.out.println( "Process "+fid+":"+t);
                            t.printStackTrace();
                            warning = false;
                        }
                    }
                }
            }, progessListener );
            transaction.commit();
           
            // TODO: we need to show our new scratch feature in the catalog view?
            return scratch;
        }
        catch (RuntimeException huh){
            transaction.rollback();
            huh.printStackTrace();
        }
        finally {
            monitor.done();
        }
View Full Code Here

Examples of org.geotools.data.DefaultTransaction

       
        monitor.beginTask(Messages.ReshapeOperation_task, 100 );

        List<Definition> transform = dialog.getTransform();
        TransformProcess process = new TransformProcess();
        DefaultTransaction transaction = new DefaultTransaction("Processing "+source.getName() ); //$NON-NLS-1$
        try {
            SimpleFeatureCollection collection = source.getFeatures();
            SimpleFeatureCollection output = process.executeList(collection, transform);

           
            final SimpleFeatureType featureType = output.getSchema();
           
            IGeoResource scratch = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource( featureType );
            final SimpleFeatureStore store = scratch.resolve(SimpleFeatureStore.class, SubMonitor.convert(monitor,Messages.ReshapeOperation_createTempSpaceTask, 10));
           
            store.setTransaction( transaction );
           
            ProgressListener progessListener = GeoToolsAdapters.progress( SubMonitor.convert(monitor,"processing "+source.getName(), 90));         //$NON-NLS-1$

            output.accepts(new FeatureVisitor(){
                boolean warning = true;
                public void visit( Feature rawFeature ) {
                    SimpleFeature feature = (SimpleFeature) rawFeature;
                    String fid = feature.getID();
                   
                    try {
                        store.addFeatures(DataUtilities.collection(feature));
                    } catch (Throwable t) {
                        if (warning) {
                            System.out.println( "Process "+fid+":"+t);
                            t.printStackTrace();
                            warning = false;
                        }
                    }
                }
            }, progessListener );
            transaction.commit();
           
            // TODO: we need to show our new scratch feature in the catalog view?
            return scratch;
        }
        catch (RuntimeException huh){
            transaction.rollback();
            huh.printStackTrace();
        }
        finally {
            monitor.done();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.