Package org.voltdb.sysprocs.saverestore

Examples of org.voltdb.sysprocs.saverestore.TableSaveFile$Container


                     mappedName = "java:comp/UserTransaction";
                  }
               }
               else if (TimerService.class.getName().equals(envRef.getType()))
               {
                  final Container ic = (Container) container;
                  InjectorFactory<?> factory = new InjectorFactory<TimerServicePropertyInjector>()
                  {
                     public TimerServicePropertyInjector create(BeanProperty property)
                     {
                        return new TimerServicePropertyInjector(property, ic);
View Full Code Here


                     mappedName = "java:comp/UserTransaction";
                  }
               }
               else if (resType.equals(TimerService.class))
               {
                  final Container ic = (Container) container;
                  InjectorFactory<?> factory = new InjectorFactory<TimerServicePropertyInjector>()
                  {
                     public TimerServicePropertyInjector create(BeanProperty property)
                     {
                        return new TimerServicePropertyInjector(property, ic);
View Full Code Here

      }
      // search everywhere
      Iterator containers = Ejb3Registry.getContainers().iterator();
      while (containers.hasNext())
      {
         Container container = (Container)containers.next();
         EJBContainer ejbContainer = (EJBContainer) container;
         if (ejbContainer == rtnContainer) continue;
         if (ProxyFactoryHelper.publishesInterface(container, businessIntf))
         {
            if (rtnContainer != null)
View Full Code Here

   public static final String PARTITION_NAME = "PARTITION_NAME";
  
   public Object invoke(Invocation invocation) throws Throwable
   {
      Container localContainer = findLocalContainer(invocation);
      if (localContainer != null)
      {
         return invokeLocal(invocation, localContainer);
      }
      return invocation.invokeNext();
View Full Code Here

   private Container findLocalContainer(Invocation invocation)
   {
      String guid = (String)invocation.getMetaData(IS_LOCAL, GUID);
      String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
     
      Container container = null;
      try
      {
         container = Ejb3Registry.findContainer(guid);
         if (container == null)
         {
View Full Code Here

    }

    private static synchronized boolean hasMoreChunks() throws IOException {
        boolean hasMoreChunks = false;
        while (!hasMoreChunks && m_saveFiles.peek() != null) {
            TableSaveFile f = m_saveFiles.peek();
            hasMoreChunks = f.hasMoreChunks();
            if (!hasMoreChunks) {
                try {
                    f.close();
                } catch (IOException e) {
                }
                m_saveFiles.poll();
            }
        }
View Full Code Here

    }

    private static synchronized BBContainer getNextChunk() throws IOException {
        BBContainer c = null;
        while (c == null && m_saveFiles.peek() != null) {
            TableSaveFile f = m_saveFiles.peek();
            LOG.trace("File Channel Size :" + f.getFileChannel().size());
            LOG.trace("File Channel Position :" + f.getFileChannel().position());
            c = f.getNextChunk();
            if (c == null) {
                LOG.trace("getNextChunk null");
                f.close();
                m_saveFiles.poll();
            }
        }
        return c;
    }
View Full Code Here

                m_fileNonce = (String) params.toArray()[1];
                LOG.trace("Checking saved table state for restore of: " + m_filePath + ", " + m_fileNonce);
                File[] savefiles = retrieveRelevantFiles(m_filePath, m_fileNonce);
                for (File file : savefiles) {
                    LOG.trace("Retrieving File :" + file);
                    TableSaveFile savefile = null;
                    try {
                        savefile = getTableSaveFile(file, 1, null);
                        try {

                            if (!savefile.getCompleted()) {
                                continue;
                            }

                            String is_replicated = "FALSE";
                            if (savefile.isReplicated()) {
                                is_replicated = "TRUE";
                            }
                            int partitionIds[] = savefile.getPartitionIds();
                            for (int pid : partitionIds) {
                                result.addRow(m_hostId, hostname, savefile.getHostId(), savefile.getHostname(), savefile.getClusterName(), savefile.getDatabaseName(), savefile.getTableName(),
                                        is_replicated, pid, savefile.getTotalPartitions());
                            }
                        } finally {
                            savefile.close();
                        }
                    } catch (FileNotFoundException e) {
                        // retrieveRelevantFiles should always generate a list
                        // of valid present files in m_filePath, so if we end up
                        // getting here, something has gone very weird.
                        e.printStackTrace();
                    } catch (IOException e) {
                        // For the time being I'm content to treat this as a
                        // missing file and let the coordinator complain if
                        // it discovers that it can't build a consistent
                        // database out of the files it sees available.
                        //
                        // Maybe just a log message? Later.
                        e.printStackTrace();
                    }
                }
            } else {
                // Initialize on other sites
                m_filePath = (String) params.toArray()[0];
                m_fileNonce = (String) params.toArray()[1];
            }

            return new DependencySet(DEP_restoreScan, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreScanResults) {
            LOG.trace("Aggregating saved table state");
            assert (dependencies.size() > 0);
            List<VoltTable> dep = dependencies.get(DEP_restoreScan);
            VoltTable result = ClusterSaveFileState.constructEmptySaveFileStateVoltTable();
            for (VoltTable table : dep) {
                while (table.advanceRow()) {
                    // the actually adds the active row... weird...
                    result.add(table);
                }
            }
            return new DependencySet(DEP_restoreScanResults, result);
        } else if (fragmentId == SysProcFragmentId.PF_restoreLoadReplicatedTable) {
            assert (params.toArray()[0] != null);
            assert (params.toArray()[1] != null);
            assert (params.toArray()[2] != null);
            String table_name = (String) params.toArray()[0];
            int dependency_id = (Integer) params.toArray()[1];
            int allowExport = (Integer) params.toArray()[2];
            LOG.trace("restoreLoadReplicatedTable :: Partition id :" + context.getPartitionExecutor().getPartitionId());
            //LOG.trace("Dependency_id :" + dependency_id + " - Loading replicated table: " + table_name);
            String result_str = "SUCCESS";
            String error_msg = "";
            TableSaveFile savefile = null;

            /**
             * For replicated tables this will do the slow thing and read the
             * file once for each ExecutionSite. This could use optimization
             * like is done with the partitioned tables.
             */
            try {
                savefile = getTableSaveFile(getSaveFileForReplicatedTable(table_name), 3, null);
                assert (savefile.getCompleted());
            } catch (IOException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            }

            try {

                while (savefile.hasMoreChunks()) {
                    VoltTable table = null;
                    final org.voltdb.utils.DBBPool.BBContainer c = savefile.getNextChunk();
                    if (c == null) {
                        continue;// Should be equivalent to break
                    }
                    VoltTable old_table = PrivateVoltTableFactory.createVoltTableFromBuffer(c.b, true);
                    Table new_catalog_table = getCatalogTable(table_name);
                    table = SavedTableConverter.convertTable(old_table, new_catalog_table);
                    c.discard();
                    try {
                        LOG.trace("LoadTable " + table_name);
                        this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
                    } catch (VoltAbortException e) {
                        result_str = "FAILURE";
                        error_msg = e.getMessage();
                        break;
                    }
                }

            } catch (IOException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            } catch (VoltTypeException e) {
                VoltTable result = constructResultsTable();
                result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
                return new DependencySet(dependency_id, result);
            }

            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, table_name, -1, result_str, error_msg);
            try {
                savefile.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return new DependencySet(dependency_id, result);
View Full Code Here

        return new File(filePath, new String(filename_builder));
    }

    private static TableSaveFile getTableSaveFile(File saveFile, int readAheadChunks, int relevantPartitionIds[]) throws IOException {
        FileInputStream savefile_input = new FileInputStream(saveFile);
        TableSaveFile savefile = new TableSaveFile(savefile_input.getChannel(), readAheadChunks, relevantPartitionIds);
        savefile.setFilePath(saveFile.getAbsolutePath());
        return savefile;
    }
View Full Code Here

    // I believe that it will work for at least one new node, but
    // there's not a good way to add a unit test for this at the moment,
    // so the emma coverage is weak.
    private VoltTable performDistributeReplicatedTable(String tableName, int siteId, SystemProcedureExecutionContext context, int allowExport) {
        String hostname = ConnectionUtil.getHostnameOrAddress();
        TableSaveFile savefile = null;
        try {
            savefile = getTableSaveFile(getSaveFileForReplicatedTable(tableName), 3, null);
            assert (savefile.getCompleted());
        } catch (IOException e) {
            VoltTable result = constructResultsTable();
            result.addRow(m_hostId, hostname, m_siteId, tableName, -1, "FAILURE", "Unable to load table: " + tableName + " error: " + e.getMessage());
            return result;
        }

        LOG.trace("Starting performDistributeReplicatedTable" + tableName);

        VoltTable[] results = null;
        results[0].addRow(m_hostId, hostname, m_siteId, tableName, -1, "SUCCESS", "NO DATA TO DISTRIBUTE");
        final Table new_catalog_table = getCatalogTable(tableName);
        Boolean needsConversion = null;
        try {

            while (savefile.hasMoreChunks()) {
                VoltTable table = null;
                final org.voltdb.utils.DBBPool.BBContainer c = savefile.getNextChunk();
                if (c == null) {
                    continue;// Should be equivalent to break
                }

                if (needsConversion == null) {
View Full Code Here

TOP

Related Classes of org.voltdb.sysprocs.saverestore.TableSaveFile$Container

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.