Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions bin/run-note.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Run a Zeppelin note headlessly, without starting Zeppelin Server
#

bin=$(dirname "${BASH_SOURCE-$0}")
bin=$(cd "${bin}">/dev/null; pwd)

. "${bin}/common.sh"

ZEPPELIN_RUN_NOTE_MAIN=org.apache.zeppelin.notebook.cli.NotebookRunner
ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/run-note.log"
JAVA_OPTS+=" -Dzeppelin.log.file=${ZEPPELIN_LOGFILE}"

if [[ -d "${ZEPPELIN_HOME}/zeppelin-server/target/classes" ]]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-server/target/classes"
fi

if [[ -d "${ZEPPELIN_HOME}/zeppelin-interpreter/target/classes" ]]; then
ZEPPELIN_CLASSPATH+=":${ZEPPELIN_HOME}/zeppelin-interpreter/target/classes"
fi

addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib"
addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib"
addJarInDir "${ZEPPELIN_HOME}/lib"
addJarInDir "${ZEPPELIN_HOME}/lib/interpreter"

CLASSPATH+=":${ZEPPELIN_CLASSPATH}"
$ZEPPELIN_RUNNER $JAVA_OPTS -cp $CLASSPATH $ZEPPELIN_RUN_NOTE_MAIN ${@}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.zeppelin.notebook.cli;

import org.apache.zeppelin.display.AngularObject;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Headless implementation of {@link AngularObjectRegistryListener}. There is no UI to broadcast
* angular object changes to in a headless run, so this only logs at debug level.
*/
public class HeadlessAngularObjectListener implements AngularObjectRegistryListener {

private static final Logger LOGGER = LoggerFactory.getLogger(HeadlessAngularObjectListener.class);

@Override
public void onAddAngularObject(String interpreterGroupId, AngularObject angularObject) {
LOGGER.debug("Angular object added in group {}: {}", interpreterGroupId,
angularObject.getName());
}

@Override
public void onUpdateAngularObject(String interpreterGroupId, AngularObject angularObject) {
LOGGER.debug("Angular object updated in group {}: {}", interpreterGroupId,
angularObject.getName());
}

@Override
public void onRemoveAngularObject(String interpreterGroupId, AngularObject angularObject) {
LOGGER.debug("Angular object removed in group {}: {}", interpreterGroupId,
angularObject.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.zeppelin.notebook.cli;

import org.apache.zeppelin.helium.ApplicationEventListener;
import org.apache.zeppelin.helium.HeliumPackage;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Headless implementation of {@link ApplicationEventListener}. Helium applications are out of
* scope for headless note execution (no UI to render them into), so this only logs at debug
* level.
*/
public class HeadlessApplicationEventListener implements ApplicationEventListener {

private static final Logger LOGGER =
LoggerFactory.getLogger(HeadlessApplicationEventListener.class);

@Override
public void onOutputAppend(String noteId, String paragraphId, int index, String appId,
String output) {
LOGGER.debug("Helium app {} output append for note {} paragraph {}", appId, noteId,
paragraphId);
}

@Override
public void onOutputUpdated(String noteId, String paragraphId, int index, String appId,
InterpreterResult.Type type, String output) {
LOGGER.debug("Helium app {} output updated for note {} paragraph {}", appId, noteId,
paragraphId);
}

@Override
public void onLoad(String noteId, String paragraphId, String appId, HeliumPackage pkg) {
LOGGER.debug("Helium app {} loaded for note {} paragraph {}", appId, noteId, paragraphId);
}

@Override
public void onStatusChange(String noteId, String paragraphId, String appId, String status) {
LOGGER.debug("Helium app {} status changed to {} for note {} paragraph {}", appId, status,
noteId, paragraphId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.zeppelin.notebook.cli;

import org.apache.zeppelin.notebook.Note;
import org.apache.zeppelin.notebook.NoteEventListener;
import org.apache.zeppelin.notebook.Paragraph;
import org.apache.zeppelin.scheduler.Job;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Headless implementation of {@link NoteEventListener}. {@link #onParagraphStatusChange} is
* printed to stdout so a blocking CLI run shows per-paragraph progress; the rest are debug-only
* since there is no UI/index to notify in a headless run.
*/
public class HeadlessNoteEventListener implements NoteEventListener {

private static final Logger LOGGER = LoggerFactory.getLogger(HeadlessNoteEventListener.class);

@Override
public void onNoteRemove(Note note, AuthenticationInfo subject) {
LOGGER.debug("Note removed: {}", note.getId());
}

@Override
public void onNoteCreate(Note note, AuthenticationInfo subject) {
LOGGER.debug("Note created: {}", note.getId());
}

@Override
public void onNoteUpdate(Note note, AuthenticationInfo subject) {
LOGGER.debug("Note updated: {}", note.getId());
}

@Override
public void onParagraphRemove(Paragraph p) {
LOGGER.debug("Paragraph removed: {}", p.getId());
}

@Override
public void onParagraphCreate(Paragraph p) {
LOGGER.debug("Paragraph created: {}", p.getId());
}

@Override
public void onParagraphUpdate(Paragraph p) {
LOGGER.debug("Paragraph updated: {}", p.getId());
}

@Override
public void onParagraphStatusChange(Paragraph p, Job.Status status) {
System.out.println("[" + p.getId() + "] " + status);
}
}
Loading
Loading