Package cascading.lingual.platform

Examples of cascading.lingual.platform.PlatformBroker


    }

  @Override
  protected boolean handle() throws IOException
    {
    PlatformBroker platformBroker = PlatformBrokerFactory.createPlatformBroker( getOptions().getPlatform(), getConfigProperties() );

    if( getOptions().isInit() )
      return init( platformBroker );

    if( !platformBroker.confirmMetaData() )
      {
      getPrinter().printFormatted( "path: %s has not been initialized, use --init", platformBroker.getFullMetadataPath() );
      return false;
      }

    boolean doNotWrite = false;

    try
      {
      Target target = null;

      if( getOptions().isDDL() )
        target = new DDLTarget( getPrinter(), getOptions() );
      if( getOptions().isListSchemas() || getOptions().isSchemaActions() )
        target = new SchemaTarget( getPrinter(), getOptions() );
      else if( getOptions().isListTables() || getOptions().isTableActions() )
        target = new TableTarget( getPrinter(), getOptions() );
      else if( getOptions().isListStereotypes() || getOptions().isStereotypeActions() )
        target = new StereotypeTarget( getPrinter(), getOptions() );
      else if( getOptions().isListFormats() || getOptions().isFormatActions() )
        target = new FormatTarget( getPrinter(), getOptions() );
      else if( getOptions().isListProtocols() || getOptions().isProtocolActions() )
        target = new ProtocolTarget( getPrinter(), getOptions() );
      else if( getOptions().isListProviders() || getOptions().isProviderActions() )
        target = new ProviderTarget( getPrinter(), getOptions() );
      else if( getOptions().isListRepos() || getOptions().isRepoActions() )
        target = new RepoTarget( getPrinter(), getOptions() );

      if( target == null )
        return getOptions().printInvalidOptionMessage( getErrPrintStream(), "no command given: missing --add, --rename, --remove, --update, --validate, --show" );

      if( !( target instanceof ProtocolTarget || target instanceof FormatTarget ) && getOptions().hasProperties() )
        return getOptions().printInvalidOptionMessage( getErrPrintStream(), "--properties may only be added to formats or protocols via --add or --update" );

      return target.handle( platformBroker );
      }
    catch( Throwable throwable )
      {
      doNotWrite = true;
      Throwables.propagate( throwable );
      return false;
      }
    finally
      {
      LOG.info( "catalog loaded: {}", platformBroker.catalogManagerLoaded() );

      if( !doNotWrite && platformBroker.catalogManagerLoaded() )
        platformBroker.commitCatalog();
      }
    }
View Full Code Here


    return rows;
    }

  private double getRowsInternal()
    {
    PlatformBroker platformBroker = getPlatformBroker();

    if( platformBroker == null )
      return super.getRows();

    SchemaCatalogManager catalog = platformBroker.getCatalogManager();

    if( catalog == null )
      return super.getRows();

    TableDef tableDef = getTapTable().getTableDef();

    try
      {
      Tap tap = catalog.createTapFor( tableDef, SinkMode.KEEP );

      if( tap != null )
        {
        if( !tap.resourceExists( platformBroker.getSystemConfig() ) )
          return 0.0;
        else if( tap instanceof FileType )
          return ( (FileType) tap ).getSize( platformBroker.getSystemConfig() ); // actually returns bytes
        }
      }
    catch( Exception exception )
      {
      LOG.warn( "unable to create tap for: " + tableDef );
View Full Code Here

    }

  @Override
  public String getDatabaseProductName() throws SQLException
    {
    PlatformBroker platformBroker = connection.getPlatformBroker();
    PlatformInfo platformInfo = platformBroker.getPlatformInfo();

    return String.format( "%s [%s %s]",
      Version.getProductName(),
      platformInfo.name,
      platformInfo.vendor
View Full Code Here

    }

  @Override
  public String getDatabaseProductVersion() throws SQLException
    {
    PlatformBroker platformBroker = connection.getPlatformBroker();
    PlatformInfo platformInfo = platformBroker.getPlatformInfo();

    return String.format( "%s [%s]",
      Version.getProductVersion(),
      platformInfo.version
    );
View Full Code Here

    }

  @Override
  public Branch visitChild( Stack stack )
    {
    PlatformBroker platformBroker = getPlatformBroker();
    TableDef tableDef = getTapTable().getTableDef();

    return new Branch( platformBroker, tableDef, getTuples() );
    }
View Full Code Here

  @Test
  public void testParseAndPersistDDL() throws IOException
    {
    Properties platformProperties = getPlatformProperties();
    PlatformBroker platformBroker = PlatformBrokerFactory.createPlatformBroker( getPlatformName(), platformProperties );

    copyFromLocal( DDL_FILE );

    initCatalog();

    catalog( "--schema", DDL_TEST_SCHEMA, "--add", getSchemaPath( DDL_TEST_SCHEMA ) );

    SchemaCatalog catalog = getSchemaCatalog();
    SchemaCatalogManager schemaCatalogManager = platformBroker.getCatalogManager();

    Protocol defaultProtocol = catalog.getSchemaDef( DDL_TEST_SCHEMA ).findDefaultProtocol();

    DDLParser parser = new DDLParser( schemaCatalogManager, DDL_TEST_SCHEMA, defaultProtocol.toString(), "csv" );
View Full Code Here

    }

  protected SchemaCatalog getSchemaCatalog()
    {
    Properties platformProperties = getPlatformProperties();
    PlatformBroker platformBroker = PlatformBrokerFactory.createPlatformBroker( getPlatformName(), platformProperties );

    return platformBroker.getCatalogManager().getSchemaCatalog();
    }
View Full Code Here

    properties.setProperty( PlatformBroker.META_DATA_DIR_NAME_PROP, "_lingual" );
    properties.setProperty( PlatformBroker.CATALOG_FILE_NAME_PROP, "catalog.json" );

    PlatformBrokerFactory.instance().reloadBrokers();

    PlatformBroker broker = PlatformBrokerFactory.createPlatformBroker( getPlatformName(), properties );

    String catalogFilePath = PlatformBroker.buildPath( "/", brokerDataPath, "_lingual", "catalog.json" );

    if( broker.pathExists( catalogFilePath ) )
      broker.deletePath( catalogFilePath );

    assertFalse( "catalog loaded", broker.catalogManagerLoaded() );

    SchemaCatalogManager catalog = broker.getCatalogManager();

    catalog.addSchemaDef( "TEST", Protocol.getProtocol( null ), Format.getFormat( null ) );

    catalog.createTableDefFor( "TEST", null, SALES_DEPTS_TABLE, (Fields) null, null, null );

    catalog.getSchemaCatalog().createStereotype( "TEST", "testStereoType", new Fields( "a", "b", "c" ) );

    assertNotNull( catalog.getSchemaDef( "TEST" ).getStereotype( "testStereoType" ) );
    assertNotNull( catalog.getSchemaDef( "TEST" ).getStereotype( "TESTSTEREOTYPE" ) );

    assertEquals( "SALES", catalog.createSchemaDefAndTableDefsFor( SALES_SCHEMA ) );

    broker.commitCatalog();

    PlatformBrokerFactory.instance().reloadBrokers();

    broker = PlatformBrokerFactory.createPlatformBroker( getPlatformName(), properties );

    catalog = broker.getCatalogManager();

    assertTrue( catalog.getSchemaNames().contains( "SALES" ) );
    assertTrue( catalog.getSchemaDef( "SALES" ).getChildTableNames().contains( "EMPS" ) );
    assertTrue( catalog.getSchemaDef( "SALES" ).getChildTableNames().contains( "DEPTS" ) );
View Full Code Here

    return tableHolder.planner;
    }

  public Enumerator enumerator()
    {
    PlatformBroker platformBroker = getPlatformBroker();
    Properties properties = platformBroker.getProperties();

    Optiq.writeSQLPlan( properties, Misc.createUniqueName(), getVolcanoPlanner() );

    FlowProcess flowProcess = platformBroker.getFlowProcess();
    SchemaCatalogManager schemaCatalog = platformBroker.getCatalogManager();

    Tap tap = schemaCatalog.createTapFor( getTableDef(), SinkMode.KEEP );
    int size = tap.getSourceFields().size();

    Type[] types = new Type[ size ];
View Full Code Here

    {
    super( index );

    // this has to happen in the constructor and not in enumerator(), since optiq is not calling
    // enumerator() for simple queries.
    PlatformBroker platformBroker = getPlatformBroker();

    if( platformBroker instanceof PlannerPlatformBroker )
      ( (PlannerPlatformBroker) platformBroker ).setTail( getBranch().current );
    }
View Full Code Here

TOP

Related Classes of cascading.lingual.platform.PlatformBroker

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.