Skip to content

Commit

Permalink
[GAE-Java] Fix log4j jar missing in grape-runtime and java pie driv…
Browse files Browse the repository at this point in the history
…er app's message strategy settable. (#2140)

- Add log4j runtime jar for logging
- Make message strategy template parameter in java driver apps
  • Loading branch information
zhanglei1949 committed Oct 18, 2022
1 parent 7d351a2 commit 77b4ec5
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 37 deletions.
33 changes: 15 additions & 18 deletions analytical_engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,39 +239,36 @@ target_link_libraries(gs_util PRIVATE
${Boost_LIBRARIES}
)

if (ENABLE_JAVA_SDK)
target_sources(gs_util PRIVATE "core/java/javasdk.cc")
target_compile_definitions(gs_util PUBLIC ENABLE_JAVA_SDK)
target_link_libraries(gs_util PRIVATE
${JAVA_JVM_LIBRARY}
${JNI_LIBRARIES}
)
endif()

add_executable(grape_engine
"core/grape_engine.cc"
"core/grape_instance.cc"
"core/java/javasdk.cc"
"core/object/dynamic.cc"
${CORE_RPC_SRC_FILES}
)
target_include_directories(grape_engine PRIVATE proto utils)

if (ENABLE_JAVA_SDK)
target_compile_definitions(grape_engine PUBLIC ENABLE_JAVA_SDK)
target_link_libraries(grape_engine PRIVATE
target_link_libraries(grape_engine PRIVATE
gs_proto
gs_util
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${CMAKE_DL_LIBS}
${Boost_LIBRARIES}
${VINEYARD_LIBRARIES}
${JAVA_JVM_LIBRARY}
${JNI_LIBRARIES}
)
else()
target_link_libraries(grape_engine PRIVATE
gs_proto
gs_util
${LIBGRAPELITE_LIBRARIES}
${GFLAGS_LIBRARIES}
${CMAKE_DL_LIBS}
${Boost_LIBRARIES}
${VINEYARD_LIBRARIES}
)
)

if (ENABLE_JAVA_SDK)
target_compile_definitions(grape_engine PUBLIC ENABLE_JAVA_SDK)
endif()

if (LET_IT_CRASH_ON_EXCEPTION)
target_compile_definitions(grape_engine PRIVATE LET_IT_CRASH_ON_EXCEPTION)
endif ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ namespace gs {
*
* @tparam FRAG_T Should be gs::ArrowProjectedFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy _message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEProjectedDefaultApp
: public AppBase<FRAG_T, JavaPIEProjectedDefaultContext<FRAG_T>>,
public grape::Communicator {
public:
// specialize the templated worker.
INSTALL_DEFAULT_WORKER(JavaPIEProjectedDefaultApp<FRAG_T>,
JavaPIEProjectedDefaultContext<FRAG_T>, FRAG_T)
JavaPIEProjectedDefaultContext<FRAG_T>, FRAG_T);
static constexpr grape::LoadStrategy load_strategy =
grape::LoadStrategy::kBothOutIn;
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
static constexpr grape::MessageStrategy message_strategy = _message_strategy;
static constexpr bool need_split_edges = true;

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.

#include "core/context/java_pie_projected_context.h"
#include "core/error.h"
#include "core/java/utils.h"

namespace gs {

Expand All @@ -35,19 +36,20 @@ namespace gs {
*
* @tparam FRAG_T Should be gs::ArrowProjectedFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy _message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEProjectedParallelApp
: public grape::ParallelAppBase<FRAG_T,
JavaPIEProjectedParallelContext<FRAG_T>>,
public grape::Communicator {
public:
// specialize the templated worker.
INSTALL_PARALLEL_WORKER(JavaPIEProjectedParallelApp<FRAG_T>,
JavaPIEProjectedParallelContext<FRAG_T>, FRAG_T)
INSTALL_JAVA_PARALLEL_WORKER(JavaPIEProjectedParallelApp<FRAG_T>,
JavaPIEProjectedParallelContext<FRAG_T>, FRAG_T)
static constexpr grape::LoadStrategy load_strategy =
grape::LoadStrategy::kBothOutIn;
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
static constexpr grape::MessageStrategy message_strategy = _message_strategy;
static constexpr bool need_split_edges = true;

public:
Expand Down
10 changes: 6 additions & 4 deletions analytical_engine/apps/java_pie/java_pie_property_default_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ namespace gs {
*
* @tparam FRAG_T Should be vineyard::ArrowFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy _message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEPropertyDefaultApp
: public PropertyAppBase<FRAG_T, JavaPIEPropertyDefaultContext<FRAG_T>>,
public grape::Communicator {
public:
// specialize the templated worker.
INSTALL_DEFAULT_PROPERTY_WORKER(JavaPIEPropertyDefaultApp<FRAG_T>,
JavaPIEPropertyDefaultContext<FRAG_T>, FRAG_T)
JavaPIEPropertyDefaultContext<FRAG_T>,
FRAG_T);
static constexpr grape::LoadStrategy load_strategy =
grape::LoadStrategy::kBothOutIn;
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
static constexpr grape::MessageStrategy message_strategy = _message_strategy;
static constexpr bool need_split_edges = true;

public:
Expand Down
15 changes: 9 additions & 6 deletions analytical_engine/apps/java_pie/java_pie_property_parallel_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ limitations under the License.
#include "core/app/parallel_property_app_base.h"
#include "core/context/java_pie_property_context.h"
#include "core/error.h"
#include "core/java/utils.h"
#include "core/worker/parallel_property_worker.h"

namespace gs {

/**
Expand All @@ -36,20 +38,21 @@ namespace gs {
*
* @tparam FRAG_T Should be vineyard::ArrowFragment<...>
*/
template <typename FRAG_T>
template <typename FRAG_T,
grape::MessageStrategy _message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex>
class JavaPIEPropertyParallelApp
: public ParallelPropertyAppBase<FRAG_T,
JavaPIEPropertyParallelContext<FRAG_T>>,
public grape::Communicator {
public:
// specialize the templated worker.
INSTALL_PARALLEL_PROPERTY_WORKER(JavaPIEPropertyParallelApp<FRAG_T>,
JavaPIEPropertyParallelContext<FRAG_T>,
FRAG_T)
INSTALL_JAVA_PARALLEL_PROPERTY_WORKER(JavaPIEPropertyParallelApp<FRAG_T>,
JavaPIEPropertyParallelContext<FRAG_T>,
FRAG_T);
static constexpr grape::LoadStrategy load_strategy =
grape::LoadStrategy::kBothOutIn;
static constexpr grape::MessageStrategy message_strategy =
grape::MessageStrategy::kAlongOutgoingEdgeToOuterVertex;
static constexpr grape::MessageStrategy message_strategy = _message_strategy;
static constexpr bool need_split_edges = true;

public:
Expand Down
20 changes: 20 additions & 0 deletions analytical_engine/core/java/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@
#include "boost/property_tree/ptree.hpp"

namespace gs {
#define INSTALL_JAVA_PARALLEL_WORKER(APP_T, CONTEXT_T, FRAG_T) \
public: \
using fragment_t = FRAG_T; \
using context_t = CONTEXT_T; \
using message_manager_t = grape::ParallelMessageManager; \
using worker_t = grape::ParallelWorker<APP_T>; \
static std::shared_ptr<worker_t> CreateWorker( \
std::shared_ptr<APP_T> app, std::shared_ptr<FRAG_T> frag) { \
return std::shared_ptr<worker_t>(new worker_t(app, frag)); \
}
#define INSTALL_JAVA_PARALLEL_PROPERTY_WORKER(APP_T, CONTEXT_T, FRAG_T) \
public: \
using fragment_t = FRAG_T; \
using context_t = CONTEXT_T; \
using message_manager_t = ParallelPropertyMessageManager; \
using worker_t = ParallelPropertyWorker<APP_T>; \
static std::shared_ptr<worker_t> CreateWorker( \
std::shared_ptr<APP_T> app, std::shared_ptr<FRAG_T> frag) { \
return std::shared_ptr<worker_t>(new worker_t(app, frag)); \
}
// data vector contains all bytes, can be used to hold oid and vdata, edata.
using byte_vector = std::vector<char>;
// offset vector contains offsets to deserialize data vector.
Expand Down
1 change: 1 addition & 0 deletions analytical_engine/java/grape-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
Expand Down
19 changes: 19 additions & 0 deletions analytical_engine/java/grape-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -105,6 +113,17 @@
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/versions/**</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
Expand Down
1 change: 1 addition & 0 deletions analytical_engine/java/graphx-on-graphscope/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<artifactId>graphx-on-graphscope</artifactId>
<packaging>jar</packaging>
<name>GraphX on GraphScope</name>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down

0 comments on commit 77b4ec5

Please sign in to comment.