Package org.elasticsearch.indices.recovery

Examples of org.elasticsearch.indices.recovery.RecoveryState$File


        List<AtomicItem> list = new ArrayList<AtomicItem>(divs.length);
        for (int index = 0; index < divs.length; index++) {
            Div d = divs[index];
            if ("page".equals(d.getTYPE())) {
                Fptr fptr = d.getFptr(0);
                File file = (File) fptr.getFILEID();
                String groupId = file.getGROUPID();
                int size = list.size();
                if (size == 0 || (size > 0 && !(groupId.equals(list.get(size - 1).getId())))) {
                    AtomicItem item = parsePage(d);
                    item.setId(groupId);
                    list.add(item);
View Full Code Here


                    if (dataStream != null) {
                        Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                        for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                            Map<String, String> stream = new HashMap<String, String>();
                            for (Fptr fptr2: fptrs) {
                                File file = (File)fptr2.getFILEID();
                                String use = file.getUSE();
                                if (entry.getValue().get(use) != null) {
                                    stream.put(use, file.getFLocat(0).getHref());
                                }
                            }
                            metsObj.getDataStreamsMap().put(entry.getKey(), stream);
                        }
                    }                   
                }
            }

            // Now we can process logicalStruct
            for (int i = 0; i < maps.length; i++) {
                StructMap structMap = maps[i];
                Div div = structMap.getDiv();
                String type = structMap.getTYPE();
                if (MetsConstants.LOGICAL.equals(type)) {
                    Map<String, CompositeItem> cimap = new HashMap<String, CompositeItem>();               
                    metsObj.setCompositeItemMap(cimap);
                    metsObj.setDescription(div.getLABEL());
                   
                    Fptr[] fptrs = div.getFptr();
                    ParameterMap dataStream = config.getDataStream();
                    if (dataStream != null) {
                        Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                        for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                            Map<String, String> stream = new HashMap<String, String>();
                            for (Fptr fptr2: fptrs) {
                                File file = (File)fptr2.getFILEID();
                                String use = file.getUSE();
                                if (entry.getValue().get(use) != null) {
                                    stream.put(use, file.getFLocat(0).getHref());
                                }
                            }
                            metsObj.getDataStreamsMap().put(entry.getKey(), stream);
                        }
                    }
View Full Code Here

    protected Object parseLogicalStruct(String oid, Div div, CompositeItem parent)
            throws DAOException {
        if ("page".equals(div.getTYPE()) || div.getDivCount() == 0) {
            if (div.getFptrCount() > 0) {
                Fptr fptr = div.getFptr(0);
                File file = (File) fptr.getFILEID();
                String groupId = file.getGROUPID();
                AtomicItem item = metsObj.getAtomicItemByID(groupId);
                item.setParent(parent);
                return item;
            } else if (div.getMptrCount() > 0) {
                Mptr mptr = div.getMptr(0);
                MetsPointerAtomicItem item = new MetsPointerAtomicItem();
                item.setType(div.getTYPE());
                item.setLabel(div.getLABEL());
                item.setParent(parent);
                item.setHref(mptr.getHref());
                return item;
            } else {
                return null;
            }
        } else {
            String type = div.getTYPE();
            String label = div.getLABEL();
            CompositeItem division = new CompositeItem();
            division.setType(type);
            division.setLabel(label);
            if (div.getCONTENTIDSCount() > 0) {
              division.setContentId(div.getCONTENTIDS(0));
            }
            if (StringUtils.isBlank(div.getID())) {
                division.setId(generateUniqueID());
            } else {
                division.setId(div.getID());
            }
            metsObj.getCompositeItemMap().put(division.getId(), division);
            if (div.getDMDIDCount() == 1) {
                DmdSec dmd = (DmdSec) div.getDMDID(0);
                division.setDmdID(dmd.getID());
            }

            Div[] divs = div.getDiv();
            division.setChildren(new ArrayList<AbstractItem>(divs.length));
            for (int i = 0; i < divs.length; i++) {
                Div d = divs[i];
                Object obj = parseLogicalStruct(oid, d, division);
                if (obj instanceof AtomicItem) {
                    // Add page to division's child list
                    division.addChild((AtomicItem) obj);
                    if (i == 0) {
                        division.setFirst((AtomicItem) obj);
                    }
                    if (i == divs.length - 1) {
                        division.setLast((AtomicItem) obj);
                    }
                } else if (obj instanceof CompositeItem) {
                    division.addChild((CompositeItem) obj);
                    if (i == 0) {
                        division.setFirst(((CompositeItem) obj).getFirst());
                    }
                    if (i == divs.length - 1) {
                        division.setLast(((CompositeItem) obj).getLast());
                    }
                }
            }

            Fptr[] fptrs = div.getFptr();
            ParameterMap dataStream = config.getDataStream();
            if (dataStream != null) {
                Map<String, Map<String, String>> valueMap = dataStream.getValueMap();
                for (Map.Entry<String, Map<String, String>> entry : valueMap.entrySet()) {
                    Map<String, String> stream = new HashMap<String, String>();
                    for (Fptr fptr2: fptrs) {
                        File file = (File)fptr2.getFILEID();
                        String use = file.getUSE();
                        if (entry.getValue().get(use) != null) {
                            stream.put(use, file.getFLocat(0).getHref());
                        }
                    }
                    division.getDataStreamsMap().put(entry.getKey(), stream);
                }
            }
View Full Code Here

        ensureGreen();

        RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").get();

        for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
            RecoveryState recoveryState = response.recoveryState();
            if (!recoveryState.getPrimary()) {
                logger.info("--> shard {}, recovered {}, reuse {}", response.getShardId(), recoveryState.getIndex().recoveredTotalSize(), recoveryState.getIndex().reusedByteCount());
                assertThat(recoveryState.getIndex().recoveredByteCount(), equalTo(0l));
                assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(0l));
                assertThat(recoveryState.getIndex().reusedByteCount(), equalTo(recoveryState.getIndex().totalByteCount()));
                assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(0));
                assertThat(recoveryState.getIndex().reusedFileCount(), equalTo(recoveryState.getIndex().totalFileCount()));
                assertThat(recoveryState.getIndex().reusedFileCount(), greaterThan(0));
                assertThat(recoveryState.getIndex().reusedByteCount(), greaterThan(recoveryState.getIndex().numberOfRecoveredBytes()));
            } else {
                assertThat(recoveryState.getIndex().recoveredByteCount(), equalTo(recoveryState.getIndex().reusedByteCount()));
                assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(recoveryState.getIndex().reusedFileCount()));
            }
        }

    }
View Full Code Here

        countResponse = client().prepareCount().get();
        assertHitCount(countResponse, numDocs);

        RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").setDetailed(true).get();
        for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
            RecoveryState recoveryState = response.recoveryState();
            if (!recoveryState.getPrimary()) {
                RecoveryState.Index index = recoveryState.getIndex();
                if (compatibilityVersion().onOrAfter(Version.V_1_2_0)) {
                    assertThat(index.toString(), index.recoveredByteCount(), equalTo(0l));
                    assertThat(index.toString(), index.reusedByteCount(), greaterThan(0l));
                    assertThat(index.toString(), index.reusedByteCount(), equalTo(index.totalByteCount()));
                    assertThat(index.toString(), index.recoveredFileCount(), equalTo(0));
View Full Code Here

        super(shardId, indexSettings);
        this.threadPool = threadPool;
        this.indexShard = (InternalIndexShard) indexShard;
        this.shardGateway = shardGateway;
        this.snapshotService = snapshotService;
        this.recoveryState = new RecoveryState(shardId);
        this.recoveryState.setType(RecoveryState.Type.GATEWAY);
        this.clusterService = clusterService;
    }
View Full Code Here

                }
            });

            for (ShardRecoveryResponse shardResponse : shardRecoveryResponses) {

                RecoveryState state = shardResponse.recoveryState();
                t.startRow();
                t.addCell(index);
                t.addCell(shardResponse.getShardId());
                t.addCell(state.getTimer().time());
                t.addCell(state.getType().toString().toLowerCase(Locale.ROOT));
                t.addCell(state.getStage().toString().toLowerCase(Locale.ROOT));
                t.addCell(state.getSourceNode() == null ? "n/a" : state.getSourceNode().getHostName());
                t.addCell(state.getTargetNode().getHostName());
                t.addCell(state.getRestoreSource() == null ? "n/a" : state.getRestoreSource().snapshotId().getRepository());
                t.addCell(state.getRestoreSource() == null ? "n/a" : state.getRestoreSource().snapshotId().getSnapshot());
                t.addCell(state.getIndex().totalFileCount());
                t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().percentFilesRecovered()));
                t.addCell(state.getIndex().totalByteCount());
                t.addCell(String.format(Locale.ROOT, "%1.1f%%", state.getIndex().percentBytesRecovered()));
                t.endRow();
            }
        }

        return t;
View Full Code Here

        InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex());
        InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id());
        ShardRecoveryResponse shardRecoveryResponse = new ShardRecoveryResponse(request.shardId());

        RecoveryState state = indexShard.recoveryState();

        if (state == null) {
            state = recoveryTarget.recoveryState(indexShard);
        }
View Full Code Here

                    // closing the shard will also cancel any ongoing recovery.
                    indexService.removeShard(shardRouting.id(), "removing shard (different instance of it allocated on this node)");
                    shardHasBeenRemoved = true;
                } else if (isPeerRecovery(shardRouting)) {
                    // check if there is an existing recovery going, and if so, and the source node is not the same, cancel the recovery to restart it
                    RecoveryState recoveryState = recoveryTarget.recoveryState(indexShard);
                    if (recoveryState != null && recoveryState.getStage() != RecoveryState.Stage.DONE) {
                        // we have an ongoing recovery, find the source based on current routing and compare them
                        DiscoveryNode sourceNode = findSourceNodeForPeerRecovery(routingTable, nodes, shardRouting);
                        if (!recoveryState.getSourceNode().equals(sourceNode)) {
                            logger.debug("[{}][{}] removing shard (recovery source changed), current [{}], global [{}])", shardRouting.index(), shardRouting.id(), currentRoutingEntry, shardRouting);
                            // closing the shard will also cancel any ongoing recovery.
                            indexService.removeShard(shardRouting.id(), "removing shard (recovery source node changed)");
                            shardHasBeenRemoved = true;
                        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.indices.recovery.RecoveryState$File

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.