Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.AkibanInformationSchema


    public void start() {
        super.start();
        final boolean clearIncompatibleData = Boolean.parseBoolean(config.getProperty(CLEAR_INCOMPATIBLE_DATA_PROP));

        initSchemaManagerDirectory();
        this.memoryTableAIS = new AkibanInformationSchema();
        this.tableStatusCache = new FDBTableStatusCache(holder, txnService);

        try(Session session = sessionService.createSession()) {
            txnService.run(session, new Runnable() {
                @Override
                public void run() {
                    TransactionState txn = txnService.getTransaction(session);
                    Boolean isCompatible = isDataCompatible(txn, false);
                    if(isCompatible == Boolean.FALSE) {
                        if(!clearIncompatibleData) {
                            isDataCompatible(txn, true);
                            assert false; // Throw expected
                        }
                        LOG.warn("Clearing incompatible data directory: {}", rootDir.getPath());
                        // Delicate: Directory removal is safe as this is the first service started that consumes it.
                        //           Remove after the 1.9.2 release, which includes entry point for doing this.
                        rootDir.remove(txn.getTransaction()).get();
                        initSchemaManagerDirectory();
                        isCompatible = null;
                    }
                    if(isCompatible == null) {
                        saveInitialState(txn);
                    }
                    AkibanInformationSchema newAIS = loadFromStorage(session);
                    buildRowDefs(session, newAIS);
                    FDBSchemaManager.this.curAIS = newAIS;
                }
            });
View Full Code Here


    @Override
    public Set<String> getTreeNames(final Session session) {
        return txnService.run(session, new Callable<Set<String>>() {
            @Override
            public Set<String> call() {
                AkibanInformationSchema ais = getAis(session);
                StorageNameVisitor visitor = new StorageNameVisitor();
                ais.visit(visitor);
                for(Sequence s : ais.getSequences().values()) {
                    visitor.visit(s);
                }
                return visitor.pathNames;
            }
        });
View Full Code Here

                        ProtobufReader reader = newProtobufReader();
                        loadProtobufChildren(txnState, protobufDir, reader, null);
                        loadPrimaryProtobuf(txnState, reader, onlineCache.schemaToOnline.keySet());
   
                        // Reader will have two copies of affected schemas, skip second (i.e. non-online)
                        AkibanInformationSchema newAIS = finishReader(reader);
                        validateAndFreeze(session, newAIS, generation);
                        buildRowDefs(session, newAIS);
                        onlineCache.onlineToAIS.put(onlineID, newAIS);
                    } else if(schemaCount != 0) {
                        throw new IllegalStateException("No generation but had schemas");
View Full Code Here

        }
    }

    @Override
    public AkibanInformationSchema getSessionAIS(Session session) {
        AkibanInformationSchema localAIS = session.get(SESSION_AIS_KEY);
        if(localAIS != null) {
            return localAIS;
        }
        TransactionState txn = txnService.getTransaction(session);
        long generation = getTransactionalGeneration(txn);
        localAIS = curAIS;
        if(generation != localAIS.getGeneration()) {
            synchronized(AIS_LOCK) {
                // May have been waiting
                if(generation == curAIS.getGeneration()) {
                    localAIS = curAIS;
                } else {
                    localAIS = loadFromStorage(session);
                    buildRowDefs(session, localAIS);
                    if(localAIS.getGeneration() > curAIS.getGeneration()) {
                        curAIS = localAIS;
                        mergeNewAIS(session, curAIS);
                    }
                }
            }
View Full Code Here

         super.unRegisterSystemRoutine(routineName);
     }

    @Override
    public void addOnlineHandledHKey(Session session, int tableID, Key hKey) {
        AkibanInformationSchema ais = getAis(session);
        OnlineCache onlineCache = getOnlineCache(session, ais);
        Long onlineID = onlineCache.tableToOnline.get(tableID);
        if(onlineID == null) {
            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
View Full Code Here

        txn.setBytes(packedKey, new byte[0]);
    }

    @Override
    public void setOnlineDMLError(Session session, int tableID, String message) {
        AkibanInformationSchema ais = getAis(session);
        OnlineCache onlineCache = getOnlineCache(session, ais);
        Long onlineID = onlineCache.tableToOnline.get(tableID);
        if(onlineID == null) {
            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
View Full Code Here

            nameGenerator.mergeAIS(onlineAIS);
        }
    }

    private void attachToSession(Session session, AkibanInformationSchema ais) {
        AkibanInformationSchema prev = session.put(SESSION_AIS_KEY, ais);
        if(prev == null) {
            txnService.addCallback(session, TransactionService.CallbackType.END, CLEAR_SESSION_KEY_CALLBACK);
        }
    }
View Full Code Here

        }
    }

    private ProtobufReader newProtobufReader() {
        // Start with existing memory tables, merge in stored ones
        final AkibanInformationSchema newAIS = aisCloner.clone(memoryTableAIS);
        return new ProtobufReader(typesRegistryService.getTypesRegistry(), storageFormatRegistry, newAIS);
    }
View Full Code Here

    protected void bumpTableVersions(Session session, AkibanInformationSchema newAIS, Collection<Integer> affectedIDs) {
        if(affectedIDs.isEmpty()) {
            return;
        }
        AkibanInformationSchema curAIS = getAISForChange(session);
        Map<Integer,Integer> newVersions = new HashMap<>();
        // Set the new table version for tables in the NewAIS
        for(Integer tableID : affectedIDs) {
            Table curTable = curAIS.getTable(tableID);
            assert (curTable != null): "null table for bump: " + tableID;
            int newVersion = curTable.getVersion() + 1;
            Table newTable = newAIS.getTable(tableID);
            // From a drop
            if(newTable != null) {
View Full Code Here

        storageFormatRegistry.unregisterMemoryFactory(tableName);
    }

    @Override
    public boolean isOnlineActive(Session session, int tableID) {
        AkibanInformationSchema ais = getAis(session);
        OnlineCache onlineCache = getOnlineCache(session, ais);
        Long onlineID = onlineCache.tableToOnline.get(tableID);
        boolean isActive = (onlineID != null);
        if(isActive) {
            OnlineSession onlineSession = getOnlineSession(session, null);
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.AkibanInformationSchema

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.