public static StorageInfo convert(StorageInfoProto info, NodeType type) { return new StorageInfo(info.getLayoutVersion(), info.getNamespceID(), info.getClusterID(), info.getCTime(), type); }
public static StorageInfoProto convert(StorageInfo info) { return StorageInfoProto.newBuilder().setClusterID(info.getClusterID()) .setCTime(info.getCTime()).setLayoutVersion(info.getLayoutVersion()) .setNamespceID(info.getNamespaceID()).build(); }
static String getParamStringForImage(NameNodeFile nnf, long txid, StorageInfo remoteStorageInfo, boolean isBootstrapStandby) { final String imageType = nnf == null ? "" : "&" + IMAGE_FILE_TYPE + "=" + nnf.name(); return "getimage=1&" + TXID_PARAM + "=" + txid + imageType + "&" + STORAGEINFO_PARAM + "=" + remoteStorageInfo.toColonSeparatedString() + "&" + IS_BOOTSTRAP_STANDBY + "=" + isBootstrapStandby; }
@Override public long getJournalCTime() throws IOException { StorageInfo sInfo = new StorageInfo((NodeType)null); sInfo.readProperties(sd); return sInfo.getCTime(); } }
/** * Get common storage fields. * Should be overloaded if additional fields need to be get. * * @param props properties * @throws IOException on error */ protected void setFieldsFromProperties( Properties props, StorageDirectory sd) throws IOException { if (props == null) { return; } setLayoutVersion(props, sd); setNamespaceID(props, sd); setcTime(props, sd); setClusterId(props, layoutVersion, sd); checkStorageType(props, sd); }
public static String getRegistrationID(StorageInfo storage) { return "NS-" + Integer.toString(storage.getNamespaceID()) + "-" + storage.getClusterID() + "-" + Long.toString(storage.getCTime()); }
public static String getRegistrationID(StorageInfo storage) { return "NS-" + Integer.toString(storage.getNamespaceID()) + "-" + Integer.toString(storage.getLayoutVersion()) + "-" + Long.toString(storage.getCTime()); }
+ " does not contain previous fs state."); storage.readProperties(sd); return false; prevStorage.readPreviousVersionProperties(sd); if (prevStorage.getLayoutVersion() != targetLayoutVersion) { throw new IOException( "Cannot rollback to storage version " + prevStorage.getLayoutVersion() + " using this version of the NameNode, which uses storage version " + targetLayoutVersion + ". " +
@Override // NodeRegistration public int getVersion() { return storageInfo.getLayoutVersion(); }
+ ".\n old LV = " + si.getLayoutVersion() + "; old CTime = " + si.getCTime() + ".\n new LV = " + nsInfo.getLayoutVersion() + "; new CTime = " + nsInfo.getCTime()); upgrade(si.getLayoutVersion(), nsInfo.getLayoutVersion(), tmpDir, curDir); } catch (Throwable t) {
/** * After one of the BPServiceActors registers successfully with the * NN, it calls this function to verify that the NN it connected to * is consistent with other NNs serving the block-pool. */ void registrationSucceeded(BPServiceActor bpServiceActor, DatanodeRegistration reg) throws IOException { writeLock(); try { if (bpRegistration != null) { checkNSEquality(bpRegistration.getStorageInfo().getNamespaceID(), reg.getStorageInfo().getNamespaceID(), "namespace ID"); checkNSEquality(bpRegistration.getStorageInfo().getClusterID(), reg.getStorageInfo().getClusterID(), "cluster ID"); } bpRegistration = reg; dn.bpRegistrationSucceeded(bpRegistration, getBlockPoolId()); // Add the initial block token secret keys to the DN's secret manager. if (dn.isBlockTokenEnabled) { dn.blockPoolTokenSecretManager.addKeys(getBlockPoolId(), reg.getExportedKeys()); } } finally { writeUnlock(); } }
private void verifySoftwareVersion(DatanodeRegistration dnReg) throws IncorrectVersionException { String dnVersion = dnReg.getSoftwareVersion(); if (VersionUtil.compareVersions(dnVersion, minimumDataNodeVersion) < 0) { IncorrectVersionException ive = new IncorrectVersionException( minimumDataNodeVersion, dnVersion, "DataNode", "NameNode"); LOG.warn(ive.getMessage() + " DN: " + dnReg); throw ive; } String nnVersion = VersionInfo.getVersion(); if (!dnVersion.equals(nnVersion)) { String messagePrefix = "Reported DataNode version '" + dnVersion + "' of DN " + dnReg + " does not match NameNode version '" + nnVersion + "'"; long nnCTime = nn.getFSImage().getStorage().getCTime(); long dnCTime = dnReg.getStorageInfo().getCTime(); if (nnCTime != dnCTime) { IncorrectVersionException ive = new IncorrectVersionException( messagePrefix + " and CTime of DN ('" + dnCTime + "') does not match CTime of NN ('" + nnCTime + "')"); LOG.warn(ive.toString(), ive); throw ive; } else { LOG.info(messagePrefix + ". Note: This is normal during a rolling upgrade."); } } }
.findImageFile(Mockito.any(NameNodeFile.class), Mockito.anyLong()); Mockito.doReturn(new StorageInfo(1, 1, "X", 1, NodeType.NAME_NODE).toColonSeparatedString()) .when(dstImage).toColonSeparatedString();
LOG.info("Setting up storage: nsid={};bpid={};lv={};" + "nsInfo={};dnuuid={}", bpStorage.getNamespaceID(), bpid, storage.getLayoutVersion(), nsInfo, storage.getDatanodeUuid());
/** Validate and set layout version from {@link Properties}*/ protected void setLayoutVersion(Properties props, StorageDirectory sd) throws IncorrectVersionException, InconsistentFSStateException { int lv = Integer.parseInt(getProperty(props, sd, "layoutVersion")); if (lv < getServiceLayoutVersion()) { // future version throw new IncorrectVersionException(getServiceLayoutVersion(), lv, "storage directory " + sd.root.getAbsolutePath()); } layoutVersion = lv; }
/** Validate and set clusterId from {@link Properties}*/ protected void setClusterId(Properties props, int layoutVersion, StorageDirectory sd) throws InconsistentFSStateException { // Set cluster ID in version that supports federation if (LayoutVersion.supports(getServiceLayoutFeatureMap(), Feature.FEDERATION, layoutVersion)) { String cid = getProperty(props, sd, "clusterID"); if (!(clusterID.equals("") || cid.equals("") || clusterID.equals(cid))) { throw new InconsistentFSStateException(sd.getRoot(), "cluster Id is incompatible with others."); } clusterID = cid; } }
private boolean checkStorageInfoOrSendError(JNStorage storage, HttpServletRequest request, HttpServletResponse response) throws IOException { int myNsId = storage.getNamespaceID(); String myClusterId = storage.getClusterID(); String theirStorageInfoString = StringEscapeUtils.escapeHtml4( request.getParameter(STORAGEINFO_PARAM)); if (theirStorageInfoString != null) { int theirNsId = StorageInfo.getNsIdFromColonSeparatedString( theirStorageInfoString); String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString( theirStorageInfoString); if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) { String msg = "This node has namespaceId '" + myNsId + " and clusterId '" + myClusterId + "' but the requesting node expected '" + theirNsId + "' and '" + theirClusterId + "'"; response.sendError(HttpServletResponse.SC_FORBIDDEN, msg); LOG.warn("Received an invalid request file transfer request from " + request.getRemoteAddr() + ": " + msg); return false; } } return true; }
/** Validate and set ctime from {@link Properties}*/ protected void setcTime(Properties props, StorageDirectory sd) throws InconsistentFSStateException { cTime = Long.parseLong(getProperty(props, sd, "cTime")); }
public static String getRegistrationID(StorageInfo storage) { return "NS-" + Integer.toString(storage.getNamespaceID()) + "-" + Integer.toString(storage.getLayoutVersion()) + "-" + Long.toString(storage.getCTime()); }
public static String getRegistrationID(StorageInfo storage) { return "NS-" + Integer.toString(storage.getNamespaceID()) + "-" + storage.getClusterID() + "-" + Long.toString(storage.getCTime()); }