felixcheung commented on a change in pull request #3320: [ZEPPELIN-3977]. Create shell script for converting old note file to new file URL: https://github.com/apache/zeppelin/pull/3320#discussion_r265339525
########## File path: zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java ########## @@ -62,59 +63,84 @@ public void init(ZeppelinConfiguration conf) throws IOException { oneWaySync = conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_ONE_WAY_SYNC); String allStorageClassNames = conf.getNotebookStorageClass().trim(); if (allStorageClassNames.isEmpty()) { - allStorageClassNames = defaultStorage; + allStorageClassNames = DEFAULT_STORAGE; LOGGER.warn("Empty ZEPPELIN_NOTEBOOK_STORAGE conf parameter, using default {}", - defaultStorage); + DEFAULT_STORAGE); } String[] storageClassNames = allStorageClassNames.split(","); if (storageClassNames.length > getMaxRepoNum()) { LOGGER.warn("Unsupported number {} of storage classes in ZEPPELIN_NOTEBOOK_STORAGE : {}\n" + "first {} will be used", storageClassNames.length, allStorageClassNames, getMaxRepoNum()); } + // init the underlying NotebookRepo for (int i = 0; i < Math.min(storageClassNames.length, getMaxRepoNum()); i++) { NotebookRepo notebookRepo = PluginManager.get().loadNotebookRepo(storageClassNames[i].trim()); if (notebookRepo != null) { notebookRepo.init(conf); repos.add(notebookRepo); } } + // couldn't initialize any storage, use default if (getRepoCount() == 0) { - LOGGER.info("No storage could be initialized, using default {} storage", defaultStorage); - NotebookRepo defaultNotebookRepo = PluginManager.get().loadNotebookRepo(defaultStorage); + LOGGER.info("No storage could be initialized, using default {} storage", DEFAULT_STORAGE); + NotebookRepo defaultNotebookRepo = PluginManager.get().loadNotebookRepo(DEFAULT_STORAGE); defaultNotebookRepo.init(conf); repos.add(defaultNotebookRepo); } + // sync for anonymous mode on start + if (getRepoCount() > 1 && conf.getBoolean(ConfVars.ZEPPELIN_ANONYMOUS_ALLOWED)) { + try { + sync(AuthenticationInfo.ANONYMOUS); + } catch (IOException e) { + LOGGER.error("Couldn't sync anonymous mode on start ", e); + } + } + } + + // Zeppelin change its note file name structure in 0.9.0, this is called when upgrading + // from 0.9.0 before to 0.9.0 after + public void convertNoteFiles(ZeppelinConfiguration conf, boolean deleteOld) throws IOException { // convert old note file (noteId/note.json) to new note file (note_name_note_id.zpln) - boolean convertToNew = conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_NEW_FORMAT_CONVERT); - boolean deleteOld = conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_NEW_FORMAT_DELETE_OLD); - if (convertToNew) { - NotebookRepo newNotebookRepo = repos.get(0); + for (int i = 0; i < repos.size(); ++i) { + NotebookRepo newNotebookRepo = repos.get(i); OldNotebookRepo oldNotebookRepo = - PluginManager.get().loadOldNotebookRepo(newNotebookRepo.getClass().getCanonicalName()); + PluginManager.get().loadOldNotebookRepo(newNotebookRepo.getClass().getCanonicalName()); oldNotebookRepo.init(conf); List<OldNoteInfo> oldNotesInfo = oldNotebookRepo.list(AuthenticationInfo.ANONYMOUS); LOGGER.info("Convert old note file to new style, note count: " + oldNotesInfo.size()); + LOGGER.info("Delete old note: " + deleteOld); Review comment: I think w/ version we should check here if the note is "old" format before converting it ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services