A class represents a java app assert node in a DAG that holds the jar file. It holds neccessary resouces to run a java app, including java class path, the gar file which consists jar and configuration yaml, and the specified java class. On creating a JavaApp, graphscope will try to load
| 137 | |
| 138 | |
| 139 | class JavaApp(AppAssets): |
| 140 | """A class represents a java app assert node in a DAG that holds the jar file. |
| 141 | |
| 142 | It holds neccessary resouces to run a java app, including java class path, the gar |
| 143 | file which consists jar and configuration yaml, and the specified java class. |
| 144 | On creating a JavaApp, graphscope will try to load the specified java class, and parse |
| 145 | the Base class for your app, and the base class for your Context Class. This operation |
| 146 | requires a java runtime environment installed in your client machine where your graphscope |
| 147 | session is created. |
| 148 | |
| 149 | To run your app, provide `JavaApp` with a property or projected graph and your querying args. |
| 150 | |
| 151 | """ |
| 152 | |
| 153 | def __init__(self, full_jar_path: str, java_app_class: str): |
| 154 | """Init JavaApp with the full path of your `jar` file and the fully-qualified name of your |
| 155 | app class. |
| 156 | |
| 157 | Args: |
| 158 | full_jar_path (str): The path where the jar file exists. |
| 159 | java_app_class (str): the fully-qualified name of your app class. |
| 160 | """ |
| 161 | self._java_app_class = java_app_class |
| 162 | self._full_jar_path = full_jar_path |
| 163 | self._jar_name = Path(self._full_jar_path).name |
| 164 | gar = self._pack_jar(self._full_jar_path) |
| 165 | gs_config = { |
| 166 | "app": [ |
| 167 | { |
| 168 | "algo": "java_app", |
| 169 | "type": "java_pie", |
| 170 | "java_jar_path": self._full_jar_path, |
| 171 | "java_app_class": self.java_app_class, |
| 172 | } |
| 173 | ] |
| 174 | } |
| 175 | # extract java app type with help of java class. |
| 176 | self._java_app_type, self._frag_param_str, _java_ctx_type = _parse_user_app( |
| 177 | java_app_class, full_jar_path |
| 178 | ) |
| 179 | # For four different java type, we use two different driver class |
| 180 | if self._java_app_type not in POSSIBLE_APP_TYPES: |
| 181 | raise RuntimeError("Unexpected app type: {}".format(self._java_app_type)) |
| 182 | if self._java_app_type.find("property") != -1: |
| 183 | gs_config["app"][0]["compatible_graph"] = ["vineyard::ArrowFragment"] |
| 184 | else: |
| 185 | gs_config["app"][0]["compatible_graph"] = ["gs::ArrowProjectedFragment"] |
| 186 | |
| 187 | gs_config["app"][0]["context_type"] = _java_ctx_type |
| 188 | if self._java_app_type == "default_property": |
| 189 | gs_config["app"][0][ |
| 190 | "driver_header" |
| 191 | ] = "apps/java_pie/java_pie_property_default_app.h" |
| 192 | gs_config["app"][0]["class_name"] = "gs::JavaPIEPropertyDefaultApp" |
| 193 | elif self._java_app_type == "parallel_property": |
| 194 | gs_config["app"][0][ |
| 195 | "driver_header" |
| 196 | ] = "apps/java_pie/java_pie_property_parallel_app.h" |
no outgoing calls