repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/ssh/SshCommandUserInfo.java | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandMessage.java
// public class SshCommandMessage {
// private String message;
// private SshCommandDrop<Boolean> drop;
//
// public SshCommandMessage(String message, SshCommandDrop<Boolean> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public String getMessage() {
// return message;
// }
//
// public SshCommandDrop<Boolean> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPassword.java
// public class SshCommandPassword {
// private String message;
// private SshCommandDrop<String> drop;
//
// public SshCommandPassword(String message, SshCommandDrop<String> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
//
// public String getMessage() {
// return message;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandYesNo.java
// public class SshCommandYesNo {
// private String message;
// private SshCommandDrop<Boolean> drop;
//
// public SshCommandYesNo(String message, SshCommandDrop<Boolean> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public String getMessage() {
// return message;
// }
//
// public SshCommandDrop<Boolean> getDrop() {
// return drop;
// }
// }
| import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.model.event.SshCommandMessage;
import it.skarafaz.mercury.model.event.SshCommandPassword;
import it.skarafaz.mercury.model.event.SshCommandYesNo;
import org.greenrobot.eventbus.EventBus; |
@Override
public String getPassword() {
return password;
}
@Override
public boolean promptPassword(String message) {
SshCommandDrop<String> drop = new SshCommandDrop<>();
message = String.format(MercuryApplication.getContext().getString(R.string.type_login_password), message.toLowerCase());
EventBus.getDefault().postSticky(new SshCommandPassword(message, drop));
password = drop.take();
return password != null;
}
@Override
public boolean promptPassphrase(String message) {
return false;
}
@Override
public boolean promptYesNo(String message) {
SshCommandDrop<Boolean> drop = new SshCommandDrop<>();
EventBus.getDefault().postSticky(new SshCommandYesNo(message, drop));
return drop.take();
}
@Override
public void showMessage(String message) {
SshCommandDrop<Boolean> drop = new SshCommandDrop<>(); | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandMessage.java
// public class SshCommandMessage {
// private String message;
// private SshCommandDrop<Boolean> drop;
//
// public SshCommandMessage(String message, SshCommandDrop<Boolean> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public String getMessage() {
// return message;
// }
//
// public SshCommandDrop<Boolean> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPassword.java
// public class SshCommandPassword {
// private String message;
// private SshCommandDrop<String> drop;
//
// public SshCommandPassword(String message, SshCommandDrop<String> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
//
// public String getMessage() {
// return message;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandYesNo.java
// public class SshCommandYesNo {
// private String message;
// private SshCommandDrop<Boolean> drop;
//
// public SshCommandYesNo(String message, SshCommandDrop<Boolean> drop) {
// this.message = message;
// this.drop = drop;
// }
//
// public String getMessage() {
// return message;
// }
//
// public SshCommandDrop<Boolean> getDrop() {
// return drop;
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandUserInfo.java
import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.model.event.SshCommandMessage;
import it.skarafaz.mercury.model.event.SshCommandPassword;
import it.skarafaz.mercury.model.event.SshCommandYesNo;
import org.greenrobot.eventbus.EventBus;
@Override
public String getPassword() {
return password;
}
@Override
public boolean promptPassword(String message) {
SshCommandDrop<String> drop = new SshCommandDrop<>();
message = String.format(MercuryApplication.getContext().getString(R.string.type_login_password), message.toLowerCase());
EventBus.getDefault().postSticky(new SshCommandPassword(message, drop));
password = drop.take();
return password != null;
}
@Override
public boolean promptPassphrase(String message) {
return false;
}
@Override
public boolean promptYesNo(String message) {
SshCommandDrop<Boolean> drop = new SshCommandDrop<>();
EventBus.getDefault().postSticky(new SshCommandYesNo(message, drop));
return drop.take();
}
@Override
public void showMessage(String message) {
SshCommandDrop<Boolean> drop = new SshCommandDrop<>(); | EventBus.getDefault().postSticky(new SshCommandMessage(message, drop)); |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/model/event/SshCommandConfirm.java | // Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandDrop.java
// public class SshCommandDrop<E> {
// private static final Logger logger = LoggerFactory.getLogger(SshCommandDrop.class);
// private E obj;
// private boolean empty = true;
//
// public synchronized E take() {
// while (empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = true;
// notifyAll();
// return obj;
// }
//
// public synchronized void put(E obj) {
// while (!empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = false;
// this.obj = obj;
// notifyAll();
// }
// }
| import it.skarafaz.mercury.ssh.SshCommandDrop; | /*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.model.event;
public class SshCommandConfirm {
private String cmd; | // Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandDrop.java
// public class SshCommandDrop<E> {
// private static final Logger logger = LoggerFactory.getLogger(SshCommandDrop.class);
// private E obj;
// private boolean empty = true;
//
// public synchronized E take() {
// while (empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = true;
// notifyAll();
// return obj;
// }
//
// public synchronized void put(E obj) {
// while (!empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = false;
// this.obj = obj;
// notifyAll();
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandConfirm.java
import it.skarafaz.mercury.ssh.SshCommandDrop;
/*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.model.event;
public class SshCommandConfirm {
private String cmd; | private SshCommandDrop<Boolean> drop; |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/ssh/SshCommandPubKey.java | // Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPubKeyInput.java
// public class SshCommandPubKeyInput {
// SshCommandDrop<String> drop;
//
// public SshCommandPubKeyInput(SshCommandDrop<String> drop) {
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/manager/SshManager.java
// public class SshManager {
// private static final String SSH_DIR = "ssh";
// private static final String KNOWN_HOSTS_FILE = "known_hosts";
// private static final int PRIVATE_KEY_LENGTH = 2048;
// private static final String PRIVATE_KEY_FILE = "id_rsa";
// private static final String PUBLIC_KEY_FILE = "id_rsa.pub";
// private static final String PUBLIC_KEY_COMMENT = "mercuryssh";
// private static final Logger logger = LoggerFactory.getLogger(SshCommandRegular.class);
// private static SshManager instance;
// private JSch jsch;
//
// private SshManager() {
// this.jsch = new JSch();
// }
//
// public static synchronized SshManager getInstance() {
// if (instance == null) {
// instance = new SshManager();
// }
// return instance;
// }
//
// public File getKnownHosts() throws IOException {
// File file = getKnownHostsFile();
// file.createNewFile();
// return file;
// }
//
// public File getPrivateKey() throws IOException, JSchException {
// File file = getPrivateKeyFile();
// if (!file.exists()) {
// generatePrivateKey(file);
// }
// return file;
// }
//
// public File getPublicKey() throws IOException, JSchException {
// File file = getPublicKeyFile();
// if (!file.exists()) {
// generatePublicKey(file);
// }
// return file;
// }
//
// public String getPublicKeyContent() throws IOException, JSchException {
// return FileUtils.readFileToString(getPublicKey()).replace("\n", "");
// }
//
// public File getPublicKeyExportedFile() {
// return new File(Environment.getExternalStorageDirectory(), PUBLIC_KEY_FILE);
// }
//
// public ExportPublicKeyStatus exportPublicKey() {
// ExportPublicKeyStatus status = ExportPublicKeyStatus.SUCCESS;
// if (MercuryApplication.isExternalStorageWritable()) {
// if (MercuryApplication.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// try {
// FileUtils.copyFile(getPublicKey(), getPublicKeyExportedFile());
// } catch (JSchException | IOException e) {
// status = ExportPublicKeyStatus.ERROR;
// logger.error(e.getMessage().replace("\n", " "));
// }
// } else {
// status = ExportPublicKeyStatus.PERMISSION;
// }
// } else {
// status = ExportPublicKeyStatus.CANNOT_WRITE_EXT_STORAGE;
// }
// return status;
// }
//
// private File getKnownHostsFile() {
// return new File(getSshDir(), KNOWN_HOSTS_FILE);
// }
//
// private File getPrivateKeyFile() {
// return new File(getSshDir(), PRIVATE_KEY_FILE);
// }
//
// private File getPublicKeyFile() {
// return new File(getSshDir(), PUBLIC_KEY_FILE);
// }
//
// private File getSshDir() {
// return MercuryApplication.getContext().getDir(SSH_DIR, Context.MODE_PRIVATE);
// }
//
// private void generatePrivateKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, PRIVATE_KEY_LENGTH);
// kpair.writePrivateKey(file.getAbsolutePath());
// kpair.dispose();
// }
//
// private void generatePublicKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.load(jsch, getPrivateKey().getAbsolutePath());
// kpair.writePublicKey(file.getAbsolutePath(), PUBLIC_KEY_COMMENT);
// kpair.dispose();
// }
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.model.event.SshCommandPubKeyInput;
import it.skarafaz.mercury.manager.SshManager;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* Mercury-SSH
* Copyright (C) 2017 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.ssh;
public class SshCommandPubKey extends SshCommand {
private static final Logger logger = LoggerFactory.getLogger(SshCommandPubKey.class);
private String pubKey;
public SshCommandPubKey() {
super();
}
@Override
protected boolean beforeExecute() {
SshCommandDrop<String> drop = new SshCommandDrop<>(); | // Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPubKeyInput.java
// public class SshCommandPubKeyInput {
// SshCommandDrop<String> drop;
//
// public SshCommandPubKeyInput(SshCommandDrop<String> drop) {
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/manager/SshManager.java
// public class SshManager {
// private static final String SSH_DIR = "ssh";
// private static final String KNOWN_HOSTS_FILE = "known_hosts";
// private static final int PRIVATE_KEY_LENGTH = 2048;
// private static final String PRIVATE_KEY_FILE = "id_rsa";
// private static final String PUBLIC_KEY_FILE = "id_rsa.pub";
// private static final String PUBLIC_KEY_COMMENT = "mercuryssh";
// private static final Logger logger = LoggerFactory.getLogger(SshCommandRegular.class);
// private static SshManager instance;
// private JSch jsch;
//
// private SshManager() {
// this.jsch = new JSch();
// }
//
// public static synchronized SshManager getInstance() {
// if (instance == null) {
// instance = new SshManager();
// }
// return instance;
// }
//
// public File getKnownHosts() throws IOException {
// File file = getKnownHostsFile();
// file.createNewFile();
// return file;
// }
//
// public File getPrivateKey() throws IOException, JSchException {
// File file = getPrivateKeyFile();
// if (!file.exists()) {
// generatePrivateKey(file);
// }
// return file;
// }
//
// public File getPublicKey() throws IOException, JSchException {
// File file = getPublicKeyFile();
// if (!file.exists()) {
// generatePublicKey(file);
// }
// return file;
// }
//
// public String getPublicKeyContent() throws IOException, JSchException {
// return FileUtils.readFileToString(getPublicKey()).replace("\n", "");
// }
//
// public File getPublicKeyExportedFile() {
// return new File(Environment.getExternalStorageDirectory(), PUBLIC_KEY_FILE);
// }
//
// public ExportPublicKeyStatus exportPublicKey() {
// ExportPublicKeyStatus status = ExportPublicKeyStatus.SUCCESS;
// if (MercuryApplication.isExternalStorageWritable()) {
// if (MercuryApplication.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// try {
// FileUtils.copyFile(getPublicKey(), getPublicKeyExportedFile());
// } catch (JSchException | IOException e) {
// status = ExportPublicKeyStatus.ERROR;
// logger.error(e.getMessage().replace("\n", " "));
// }
// } else {
// status = ExportPublicKeyStatus.PERMISSION;
// }
// } else {
// status = ExportPublicKeyStatus.CANNOT_WRITE_EXT_STORAGE;
// }
// return status;
// }
//
// private File getKnownHostsFile() {
// return new File(getSshDir(), KNOWN_HOSTS_FILE);
// }
//
// private File getPrivateKeyFile() {
// return new File(getSshDir(), PRIVATE_KEY_FILE);
// }
//
// private File getPublicKeyFile() {
// return new File(getSshDir(), PUBLIC_KEY_FILE);
// }
//
// private File getSshDir() {
// return MercuryApplication.getContext().getDir(SSH_DIR, Context.MODE_PRIVATE);
// }
//
// private void generatePrivateKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, PRIVATE_KEY_LENGTH);
// kpair.writePrivateKey(file.getAbsolutePath());
// kpair.dispose();
// }
//
// private void generatePublicKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.load(jsch, getPrivateKey().getAbsolutePath());
// kpair.writePublicKey(file.getAbsolutePath(), PUBLIC_KEY_COMMENT);
// kpair.dispose();
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandPubKey.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.model.event.SshCommandPubKeyInput;
import it.skarafaz.mercury.manager.SshManager;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Mercury-SSH
* Copyright (C) 2017 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.ssh;
public class SshCommandPubKey extends SshCommand {
private static final Logger logger = LoggerFactory.getLogger(SshCommandPubKey.class);
private String pubKey;
public SshCommandPubKey() {
super();
}
@Override
protected boolean beforeExecute() {
SshCommandDrop<String> drop = new SshCommandDrop<>(); | EventBus.getDefault().postSticky(new SshCommandPubKeyInput(drop)); |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/ssh/SshCommandPubKey.java | // Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPubKeyInput.java
// public class SshCommandPubKeyInput {
// SshCommandDrop<String> drop;
//
// public SshCommandPubKeyInput(SshCommandDrop<String> drop) {
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/manager/SshManager.java
// public class SshManager {
// private static final String SSH_DIR = "ssh";
// private static final String KNOWN_HOSTS_FILE = "known_hosts";
// private static final int PRIVATE_KEY_LENGTH = 2048;
// private static final String PRIVATE_KEY_FILE = "id_rsa";
// private static final String PUBLIC_KEY_FILE = "id_rsa.pub";
// private static final String PUBLIC_KEY_COMMENT = "mercuryssh";
// private static final Logger logger = LoggerFactory.getLogger(SshCommandRegular.class);
// private static SshManager instance;
// private JSch jsch;
//
// private SshManager() {
// this.jsch = new JSch();
// }
//
// public static synchronized SshManager getInstance() {
// if (instance == null) {
// instance = new SshManager();
// }
// return instance;
// }
//
// public File getKnownHosts() throws IOException {
// File file = getKnownHostsFile();
// file.createNewFile();
// return file;
// }
//
// public File getPrivateKey() throws IOException, JSchException {
// File file = getPrivateKeyFile();
// if (!file.exists()) {
// generatePrivateKey(file);
// }
// return file;
// }
//
// public File getPublicKey() throws IOException, JSchException {
// File file = getPublicKeyFile();
// if (!file.exists()) {
// generatePublicKey(file);
// }
// return file;
// }
//
// public String getPublicKeyContent() throws IOException, JSchException {
// return FileUtils.readFileToString(getPublicKey()).replace("\n", "");
// }
//
// public File getPublicKeyExportedFile() {
// return new File(Environment.getExternalStorageDirectory(), PUBLIC_KEY_FILE);
// }
//
// public ExportPublicKeyStatus exportPublicKey() {
// ExportPublicKeyStatus status = ExportPublicKeyStatus.SUCCESS;
// if (MercuryApplication.isExternalStorageWritable()) {
// if (MercuryApplication.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// try {
// FileUtils.copyFile(getPublicKey(), getPublicKeyExportedFile());
// } catch (JSchException | IOException e) {
// status = ExportPublicKeyStatus.ERROR;
// logger.error(e.getMessage().replace("\n", " "));
// }
// } else {
// status = ExportPublicKeyStatus.PERMISSION;
// }
// } else {
// status = ExportPublicKeyStatus.CANNOT_WRITE_EXT_STORAGE;
// }
// return status;
// }
//
// private File getKnownHostsFile() {
// return new File(getSshDir(), KNOWN_HOSTS_FILE);
// }
//
// private File getPrivateKeyFile() {
// return new File(getSshDir(), PRIVATE_KEY_FILE);
// }
//
// private File getPublicKeyFile() {
// return new File(getSshDir(), PUBLIC_KEY_FILE);
// }
//
// private File getSshDir() {
// return MercuryApplication.getContext().getDir(SSH_DIR, Context.MODE_PRIVATE);
// }
//
// private void generatePrivateKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, PRIVATE_KEY_LENGTH);
// kpair.writePrivateKey(file.getAbsolutePath());
// kpair.dispose();
// }
//
// private void generatePublicKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.load(jsch, getPrivateKey().getAbsolutePath());
// kpair.writePublicKey(file.getAbsolutePath(), PUBLIC_KEY_COMMENT);
// kpair.dispose();
// }
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.model.event.SshCommandPubKeyInput;
import it.skarafaz.mercury.manager.SshManager;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | @Override
protected boolean beforeExecute() {
SshCommandDrop<String> drop = new SshCommandDrop<>();
EventBus.getDefault().postSticky(new SshCommandPubKeyInput(drop));
String input = drop.take();
if (input == null) {
return false;
}
setHostPortUser(input);
return super.beforeExecute();
}
private void setHostPortUser(String input) {
String[] sInput = input.split("@");
String left = sInput[0];
String right = sInput[1];
String[] sRight = right.split(":");
this.host = sRight[0];
this.port = sRight.length > 1 ? Integer.valueOf(sRight[1]) : 22;
this.user = left;
}
@Override
protected boolean initConnection() {
boolean success = true;
try { | // Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandPubKeyInput.java
// public class SshCommandPubKeyInput {
// SshCommandDrop<String> drop;
//
// public SshCommandPubKeyInput(SshCommandDrop<String> drop) {
// this.drop = drop;
// }
//
// public SshCommandDrop<String> getDrop() {
// return drop;
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/manager/SshManager.java
// public class SshManager {
// private static final String SSH_DIR = "ssh";
// private static final String KNOWN_HOSTS_FILE = "known_hosts";
// private static final int PRIVATE_KEY_LENGTH = 2048;
// private static final String PRIVATE_KEY_FILE = "id_rsa";
// private static final String PUBLIC_KEY_FILE = "id_rsa.pub";
// private static final String PUBLIC_KEY_COMMENT = "mercuryssh";
// private static final Logger logger = LoggerFactory.getLogger(SshCommandRegular.class);
// private static SshManager instance;
// private JSch jsch;
//
// private SshManager() {
// this.jsch = new JSch();
// }
//
// public static synchronized SshManager getInstance() {
// if (instance == null) {
// instance = new SshManager();
// }
// return instance;
// }
//
// public File getKnownHosts() throws IOException {
// File file = getKnownHostsFile();
// file.createNewFile();
// return file;
// }
//
// public File getPrivateKey() throws IOException, JSchException {
// File file = getPrivateKeyFile();
// if (!file.exists()) {
// generatePrivateKey(file);
// }
// return file;
// }
//
// public File getPublicKey() throws IOException, JSchException {
// File file = getPublicKeyFile();
// if (!file.exists()) {
// generatePublicKey(file);
// }
// return file;
// }
//
// public String getPublicKeyContent() throws IOException, JSchException {
// return FileUtils.readFileToString(getPublicKey()).replace("\n", "");
// }
//
// public File getPublicKeyExportedFile() {
// return new File(Environment.getExternalStorageDirectory(), PUBLIC_KEY_FILE);
// }
//
// public ExportPublicKeyStatus exportPublicKey() {
// ExportPublicKeyStatus status = ExportPublicKeyStatus.SUCCESS;
// if (MercuryApplication.isExternalStorageWritable()) {
// if (MercuryApplication.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// try {
// FileUtils.copyFile(getPublicKey(), getPublicKeyExportedFile());
// } catch (JSchException | IOException e) {
// status = ExportPublicKeyStatus.ERROR;
// logger.error(e.getMessage().replace("\n", " "));
// }
// } else {
// status = ExportPublicKeyStatus.PERMISSION;
// }
// } else {
// status = ExportPublicKeyStatus.CANNOT_WRITE_EXT_STORAGE;
// }
// return status;
// }
//
// private File getKnownHostsFile() {
// return new File(getSshDir(), KNOWN_HOSTS_FILE);
// }
//
// private File getPrivateKeyFile() {
// return new File(getSshDir(), PRIVATE_KEY_FILE);
// }
//
// private File getPublicKeyFile() {
// return new File(getSshDir(), PUBLIC_KEY_FILE);
// }
//
// private File getSshDir() {
// return MercuryApplication.getContext().getDir(SSH_DIR, Context.MODE_PRIVATE);
// }
//
// private void generatePrivateKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.genKeyPair(jsch, KeyPair.RSA, PRIVATE_KEY_LENGTH);
// kpair.writePrivateKey(file.getAbsolutePath());
// kpair.dispose();
// }
//
// private void generatePublicKey(File file) throws IOException, JSchException {
// KeyPair kpair = KeyPair.load(jsch, getPrivateKey().getAbsolutePath());
// kpair.writePublicKey(file.getAbsolutePath(), PUBLIC_KEY_COMMENT);
// kpair.dispose();
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandPubKey.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.UserInfo;
import it.skarafaz.mercury.model.event.SshCommandPubKeyInput;
import it.skarafaz.mercury.manager.SshManager;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
protected boolean beforeExecute() {
SshCommandDrop<String> drop = new SshCommandDrop<>();
EventBus.getDefault().postSticky(new SshCommandPubKeyInput(drop));
String input = drop.take();
if (input == null) {
return false;
}
setHostPortUser(input);
return super.beforeExecute();
}
private void setHostPortUser(String input) {
String[] sInput = input.split("@");
String left = sInput[0];
String right = sInput[1];
String[] sRight = right.split(":");
this.host = sRight[0];
this.port = sRight.length > 1 ? Integer.valueOf(sRight[1]) : 22;
this.user = left;
}
@Override
protected boolean initConnection() {
boolean success = true;
try { | jsch.setKnownHosts(SshManager.getInstance().getKnownHosts().getAbsolutePath()); |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/model/event/SshCommandYesNo.java | // Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandDrop.java
// public class SshCommandDrop<E> {
// private static final Logger logger = LoggerFactory.getLogger(SshCommandDrop.class);
// private E obj;
// private boolean empty = true;
//
// public synchronized E take() {
// while (empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = true;
// notifyAll();
// return obj;
// }
//
// public synchronized void put(E obj) {
// while (!empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = false;
// this.obj = obj;
// notifyAll();
// }
// }
| import it.skarafaz.mercury.ssh.SshCommandDrop; | /*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.model.event;
public class SshCommandYesNo {
private String message; | // Path: app/src/main/java/it/skarafaz/mercury/ssh/SshCommandDrop.java
// public class SshCommandDrop<E> {
// private static final Logger logger = LoggerFactory.getLogger(SshCommandDrop.class);
// private E obj;
// private boolean empty = true;
//
// public synchronized E take() {
// while (empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = true;
// notifyAll();
// return obj;
// }
//
// public synchronized void put(E obj) {
// while (!empty) {
// try {
// wait();
// } catch (InterruptedException e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
// empty = false;
// this.obj = obj;
// notifyAll();
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/model/event/SshCommandYesNo.java
import it.skarafaz.mercury.ssh.SshCommandDrop;
/*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.model.event;
public class SshCommandYesNo {
private String message; | private SshCommandDrop<Boolean> drop; |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/ssh/SshEventSubscriber.java | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/activity/MercuryActivity.java
// public abstract class MercuryActivity extends AppCompatActivity {
// private static final int ACTION_BAR_ELEVATION = 0;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setActionBarElevation();
// }
//
// private void setActionBarElevation() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setElevation(ACTION_BAR_ELEVATION);
// }
// }
// }
| import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import android.support.annotation.NonNull;
import android.text.InputType;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.activity.MercuryActivity;
import it.skarafaz.mercury.model.event.*;
import org.apache.commons.lang3.StringUtils; | /*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.ssh;
@SuppressWarnings("unused")
public class SshEventSubscriber { | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/activity/MercuryActivity.java
// public abstract class MercuryActivity extends AppCompatActivity {
// private static final int ACTION_BAR_ELEVATION = 0;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setActionBarElevation();
// }
//
// private void setActionBarElevation() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setElevation(ACTION_BAR_ELEVATION);
// }
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshEventSubscriber.java
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import android.support.annotation.NonNull;
import android.text.InputType;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.activity.MercuryActivity;
import it.skarafaz.mercury.model.event.*;
import org.apache.commons.lang3.StringUtils;
/*
* Mercury-SSH
* Copyright (C) 2018 Skarafaz
*
* This file is part of Mercury-SSH.
*
* Mercury-SSH is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Mercury-SSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mercury-SSH. If not, see <http://www.gnu.org/licenses/>.
*/
package it.skarafaz.mercury.ssh;
@SuppressWarnings("unused")
public class SshEventSubscriber { | private MercuryActivity activity; |
Skarafaz/mercury | app/src/main/java/it/skarafaz/mercury/ssh/SshEventSubscriber.java | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/activity/MercuryActivity.java
// public abstract class MercuryActivity extends AppCompatActivity {
// private static final int ACTION_BAR_ELEVATION = 0;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setActionBarElevation();
// }
//
// private void setActionBarElevation() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setElevation(ACTION_BAR_ELEVATION);
// }
// }
// }
| import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import android.support.annotation.NonNull;
import android.text.InputType;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.activity.MercuryActivity;
import it.skarafaz.mercury.model.event.*;
import org.apache.commons.lang3.StringUtils; | }
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onSshCommandConfirm(final SshCommandConfirm event) {
new MaterialDialog.Builder(activity)
.title(R.string.confirm_exec)
.content(event.getCmd())
.positiveText(R.string.ok)
.negativeText(R.string.cancel)
.cancelable(false)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
event.getDrop().put(true);
}
})
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
event.getDrop().put(false);
}
})
.show();
EventBus.getDefault().removeStickyEvent(event);
}
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onSshCommandStart(SshCommandStart event) { | // Path: app/src/main/java/it/skarafaz/mercury/MercuryApplication.java
// public class MercuryApplication extends Application {
// private static final String S_HAS_PERMANENT_MENU_KEY = "sHasPermanentMenuKey";
// private static final Logger logger = LoggerFactory.getLogger(MercuryApplication.class);
// private static Context context;
//
// public static Context getContext() {
// return context;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// context = this;
//
// EventBus.builder().addIndex(new EventBusIndex()).build();
//
// // hack for devices with hw options button
// try {
// ViewConfiguration config = ViewConfiguration.get(this);
// Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY);
// if (menuKeyField != null) {
// menuKeyField.setAccessible(true);
// menuKeyField.setBoolean(config, false);
// }
// } catch (Exception e) {
// logger.error(e.getMessage().replace("\n", " "));
// }
// }
//
// public static void showProgressDialog(FragmentManager manager, String content) {
// FragmentTransaction transaction = manager.beginTransaction();
// transaction.add(ProgressDialogFragment.newInstance(content), ProgressDialogFragment.TAG);
// transaction.commitAllowingStateLoss();
// }
//
// public static void dismissProgressDialog(FragmentManager manager) {
// FragmentTransaction transaction = manager.beginTransaction();
// Fragment fragment = manager.findFragmentByTag(ProgressDialogFragment.TAG);
// if (fragment != null) {
// transaction.remove(fragment);
// }
// transaction.commitAllowingStateLoss();
// }
//
// public static boolean hasPermission(String permission) {
// return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
// }
//
// public static boolean requestPermission(Activity activity, int requestCode, String permission) {
// boolean requested = false;
// if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
// requested = true;
// }
// return requested;
// }
//
// public static boolean isExternalStorageReadable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
// }
//
// public static boolean isExternalStorageWritable() {
// String state = Environment.getExternalStorageState();
// return Environment.MEDIA_MOUNTED.equals(state);
// }
// }
//
// Path: app/src/main/java/it/skarafaz/mercury/activity/MercuryActivity.java
// public abstract class MercuryActivity extends AppCompatActivity {
// private static final int ACTION_BAR_ELEVATION = 0;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setActionBarElevation();
// }
//
// private void setActionBarElevation() {
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.setElevation(ACTION_BAR_ELEVATION);
// }
// }
// }
// Path: app/src/main/java/it/skarafaz/mercury/ssh/SshEventSubscriber.java
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import android.support.annotation.NonNull;
import android.text.InputType;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import it.skarafaz.mercury.MercuryApplication;
import it.skarafaz.mercury.R;
import it.skarafaz.mercury.activity.MercuryActivity;
import it.skarafaz.mercury.model.event.*;
import org.apache.commons.lang3.StringUtils;
}
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onSshCommandConfirm(final SshCommandConfirm event) {
new MaterialDialog.Builder(activity)
.title(R.string.confirm_exec)
.content(event.getCmd())
.positiveText(R.string.ok)
.negativeText(R.string.cancel)
.cancelable(false)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
event.getDrop().put(true);
}
})
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
event.getDrop().put(false);
}
})
.show();
EventBus.getDefault().removeStickyEvent(event);
}
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onSshCommandStart(SshCommandStart event) { | MercuryApplication.showProgressDialog(activity.getSupportFragmentManager(), activity.getString(R.string.sending_command)); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/StompPubsubClientEndpoint.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/StompSubscription.java
// public static interface Handler {
// void handle(StompFrame message);
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.StompSubscription.Handler; | private void send(StompFrame message) throws IOException {
if (session != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.write(baos);
// Send as binary
session.getBasicRemote().sendBinary(ByteBuffer.wrap(baos.toByteArray()));
}
}
public void waitForOpen() throws InterruptedException {
synchronized (this) {
while (session == null) {
this.wait();
}
}
}
private void onStompMessage(StompFrame stomp) {
switch (stomp.getCommand()) {
case CONNECTED:
String version = stomp.getHeader("version");
logger.info("STOMP CONNECTED version={}", version);
break;
case RECEIPT:
String receiptId = stomp.getHeader("receipt-id");
logger.info("STOMP RECEIPT id={}", receiptId);
break;
case MESSAGE:
String id = stomp.getHeader("subscription");
StompSubscription subscription = mapOfIdToSubscription.get(id); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/StompSubscription.java
// public static interface Handler {
// void handle(StompFrame message);
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/StompPubsubClientEndpoint.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.text.ParseException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.StompSubscription.Handler;
private void send(StompFrame message) throws IOException {
if (session != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.write(baos);
// Send as binary
session.getBasicRemote().sendBinary(ByteBuffer.wrap(baos.toByteArray()));
}
}
public void waitForOpen() throws InterruptedException {
synchronized (this) {
while (session == null) {
this.wait();
}
}
}
private void onStompMessage(StompFrame stomp) {
switch (stomp.getCommand()) {
case CONNECTED:
String version = stomp.getHeader("version");
logger.info("STOMP CONNECTED version={}", version);
break;
case RECEIPT:
String receiptId = stomp.getHeader("receipt-id");
logger.info("STOMP RECEIPT id={}", receiptId);
break;
case MESSAGE:
String id = stomp.getHeader("subscription");
StompSubscription subscription = mapOfIdToSubscription.get(id); | Handler handler = subscription.getHandler(); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionSubscribe.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.net.URI;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe to ISE SessionDirectory
*/
public class SessionSubscribe {
private static Logger logger = LoggerFactory.getLogger(SessionSubscribe.class);
// Subscribe handler class
private static class SessionHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
logger.info("Content={}", new String(message.getContent()));
}
}
public static void main(String[] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionSubscribe");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionSubscribe.java
import java.net.URI;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe to ISE SessionDirectory
*/
public class SessionSubscribe {
private static Logger logger = LoggerFactory.getLogger(SessionSubscribe.class);
// Subscribe handler class
private static class SessionHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
logger.info("Content={}", new String(message.getContent()));
}
}
public static void main(String[] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionSubscribe");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | while (control.accountActivate() != AccountState.ENABLED) { |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionSubscribe.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.net.URI;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe to ISE SessionDirectory
*/
public class SessionSubscribe {
private static Logger logger = LoggerFactory.getLogger(SessionSubscribe.class);
// Subscribe handler class
private static class SessionHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
logger.info("Content={}", new String(message.getContent()));
}
}
public static void main(String[] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionSubscribe");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceLookup for session service | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionSubscribe.java
import java.net.URI;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe to ISE SessionDirectory
*/
public class SessionSubscribe {
private static Logger logger = LoggerFactory.getLogger(SessionSubscribe.class);
// Subscribe handler class
private static class SessionHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
logger.info("Content={}", new String(message.getContent()));
}
}
public static void main(String[] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionSubscribe");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceLookup for session service | Service[] services = control.serviceLookup("com.cisco.ise.session"); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceConsumer.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.net.URI;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe a topic from a custom service
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceLookup for the custom service
* 4. pxGrid ServiceLookup for ISE pubsub service
* 5. pxGrid get AccessSecret for the ISE pubsub node
* 6. Establish WebSocket connection with the ISE pubsub node
* 7. Establish STOMP connection for pubsub messaging
* 8. Subscribe to the topic in the custom service
* 9. Wait for keyboard input for stopping the application
*/
public class CustomServiceConsumer {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
// Subscribe handler class
private static class MessageHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
System.out.println(new String(message.getContent()));
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceConsumer");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceConsumer.java
import java.net.URI;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe a topic from a custom service
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceLookup for the custom service
* 4. pxGrid ServiceLookup for ISE pubsub service
* 5. pxGrid get AccessSecret for the ISE pubsub node
* 6. Establish WebSocket connection with the ISE pubsub node
* 7. Establish STOMP connection for pubsub messaging
* 8. Subscribe to the topic in the custom service
* 9. Wait for keyboard input for stopping the application
*/
public class CustomServiceConsumer {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
// Subscribe handler class
private static class MessageHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
System.out.println(new String(message.getContent()));
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceConsumer");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | while (control.accountActivate() != AccountState.ENABLED) { |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceConsumer.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.net.URI;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe a topic from a custom service
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceLookup for the custom service
* 4. pxGrid ServiceLookup for ISE pubsub service
* 5. pxGrid get AccessSecret for the ISE pubsub node
* 6. Establish WebSocket connection with the ISE pubsub node
* 7. Establish STOMP connection for pubsub messaging
* 8. Subscribe to the topic in the custom service
* 9. Wait for keyboard input for stopping the application
*/
public class CustomServiceConsumer {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
// Subscribe handler class
private static class MessageHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
System.out.println(new String(message.getContent()));
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceConsumer");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceLookup for custom service | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceConsumer.java
import java.net.URI;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to subscribe a topic from a custom service
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceLookup for the custom service
* 4. pxGrid ServiceLookup for ISE pubsub service
* 5. pxGrid get AccessSecret for the ISE pubsub node
* 6. Establish WebSocket connection with the ISE pubsub node
* 7. Establish STOMP connection for pubsub messaging
* 8. Subscribe to the topic in the custom service
* 9. Wait for keyboard input for stopping the application
*/
public class CustomServiceConsumer {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
// Subscribe handler class
private static class MessageHandler implements StompSubscription.Handler {
@Override
public void handle(StompFrame message) {
System.out.println(new String(message.getContent()));
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceConsumer");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceLookup for custom service | Service[] services = control.serviceLookup("com.example.custom"); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryByIP.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.io.IOException;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query session by IP from ISE Session Directory service
*/
public class SessionQueryByIP {
private static Logger logger = LoggerFactory.getLogger(SessionQueryByIP.class);
private static class SessionQueryRequest {
String ipAddress;
}
private static void query(SampleConfiguration config, String ip) throws IOException {
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryByIP.java
import java.io.IOException;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query session by IP from ISE Session Directory service
*/
public class SessionQueryByIP {
private static Logger logger = LoggerFactory.getLogger(SessionQueryByIP.class);
private static class SessionQueryRequest {
String ipAddress;
}
private static void query(SampleConfiguration config, String ip) throws IOException {
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service | Service[] services = pxgrid.serviceLookup("com.cisco.ise.session"); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryByIP.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.io.IOException;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query session by IP from ISE Session Directory service
*/
public class SessionQueryByIP {
private static Logger logger = LoggerFactory.getLogger(SessionQueryByIP.class);
private static class SessionQueryRequest {
String ipAddress;
}
private static void query(SampleConfiguration config, String ip) throws IOException {
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service
Service[] services = pxgrid.serviceLookup("com.cisco.ise.session");
if (services == null || services.length == 0) {
System.out.println("Service unavailabe");
return;
}
// Use first service
Service service = services[0];
String url = service.getProperties().get("restBaseUrl") + "/getSessionByIpAddress";
logger.info("url={}", url);
// pxGrid AccessSecret for the node
String secret = pxgrid.getAccessSecret(service.getNodeName());
SessionQueryRequest req = new SessionQueryRequest();
req.ipAddress = ip;
SampleHelper.postAndPrint(url, config.getNodeName(), secret, config.getSSLContext().getSocketFactory(), req);
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionQueryByIP");
System.exit(1);
}
// AccountActivate
PxgridControl pxgrid = new PxgridControl(config); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryByIP.java
import java.io.IOException;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query session by IP from ISE Session Directory service
*/
public class SessionQueryByIP {
private static Logger logger = LoggerFactory.getLogger(SessionQueryByIP.class);
private static class SessionQueryRequest {
String ipAddress;
}
private static void query(SampleConfiguration config, String ip) throws IOException {
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service
Service[] services = pxgrid.serviceLookup("com.cisco.ise.session");
if (services == null || services.length == 0) {
System.out.println("Service unavailabe");
return;
}
// Use first service
Service service = services[0];
String url = service.getProperties().get("restBaseUrl") + "/getSessionByIpAddress";
logger.info("url={}", url);
// pxGrid AccessSecret for the node
String secret = pxgrid.getAccessSecret(service.getNodeName());
SessionQueryRequest req = new SessionQueryRequest();
req.ipAddress = ip;
SampleHelper.postAndPrint(url, config.getNodeName(), secret, config.getSSLContext().getSocketFactory(), req);
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionQueryByIP");
System.exit(1);
}
// AccountActivate
PxgridControl pxgrid = new PxgridControl(config); | while (pxgrid.accountActivate() != AccountState.ENABLED) |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
| import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | while (control.accountActivate() != AccountState.ENABLED) { |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
| import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceRegister
Map<String, String> sessionProperties = new HashMap<>();
sessionProperties.put("wsPubsubService", "com.cisco.ise.pubsub");
sessionProperties.put("customTopic", "/topic/com.example.custom"); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceRegister
Map<String, String> sessionProperties = new HashMap<>();
sessionProperties.put("wsPubsubService", "com.cisco.ise.pubsub");
sessionProperties.put("customTopic", "/topic/com.example.custom"); | ServiceRegisterResponse response = control.serviceRegister("com.example.custom", sessionProperties); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
| import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceRegister
Map<String, String> sessionProperties = new HashMap<>();
sessionProperties.put("wsPubsubService", "com.cisco.ise.pubsub");
sessionProperties.put("customTopic", "/topic/com.example.custom");
ServiceRegisterResponse response = control.serviceRegister("com.example.custom", sessionProperties);
String registrationId = response.getId();
long reregisterTimeMillis = response.getReregisterTimeMillis();
// Schedule pxGrid ServiceReregister
executor.scheduleWithFixedDelay(() -> {
try {
control.serviceReregister(registrationId);
} catch (IOException e) {
logger.error("Reregister failure");
}
}, reregisterTimeMillis, reregisterTimeMillis, TimeUnit.MILLISECONDS);
// pxGrid ServiceLookup for pubsub service | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/ServiceRegisterResponse.java
// @XmlRootElement
// public class ServiceRegisterResponse {
// private String id;
// private long reregisterTimeMillis;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public long getReregisterTimeMillis() {
// return reregisterTimeMillis;
// }
//
// public void setReregisterTimeMillis(long reregisterTimeMillis) {
// this.reregisterTimeMillis = reregisterTimeMillis;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/CustomServiceProvider.java
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.websocket.Session;
import org.apache.commons.cli.ParseException;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.client.ClientProperties;
import org.glassfish.tyrus.client.SslEngineConfigurator;
import org.glassfish.tyrus.client.auth.Credentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.cisco.pxgrid.samples.ise.model.ServiceRegisterResponse;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrate how to create a custom service that publishes data
*
* The flow of the application is as follows:
* 1. Parse arguments for configurations
* 2. Activate Account. This will then require ISE Admin to approve this new node.
* 3. pxGrid ServiceRegister to register the new custom service
* 4. Schedule periodic pxGrid ServiceReregister to signify the service is still alive
* 5. pxGrid ServiceLookup for ISE pubsub service
* 6. pxGrid get AccessSecret for the ISE pubsub node
* 7. Establish WebSocket connection with the ISE pubsub node
* 8. Establish STOMP connection for pubsub messaging
* 9. Schedule periodic publish of data
* 10. Wait for keyboard input for stopping the application
*/
public class CustomServiceProvider {
private static Logger logger = LoggerFactory.getLogger(CustomServiceProvider.class);
public static void main(String[] args) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("CustomServiceProvider");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config);
while (control.accountActivate() != AccountState.ENABLED) {
Thread.sleep(60000);
}
logger.info("pxGrid controller version={}", control.getControllerVersion());
// pxGrid ServiceRegister
Map<String, String> sessionProperties = new HashMap<>();
sessionProperties.put("wsPubsubService", "com.cisco.ise.pubsub");
sessionProperties.put("customTopic", "/topic/com.example.custom");
ServiceRegisterResponse response = control.serviceRegister("com.example.custom", sessionProperties);
String registrationId = response.getId();
long reregisterTimeMillis = response.getReregisterTimeMillis();
// Schedule pxGrid ServiceReregister
executor.scheduleWithFixedDelay(() -> {
try {
control.serviceReregister(registrationId);
} catch (IOException e) {
logger.error("Reregister failure");
}
}, reregisterTimeMillis, reregisterTimeMillis, TimeUnit.MILLISECONDS);
// pxGrid ServiceLookup for pubsub service | Service[] services = control.serviceLookup("com.cisco.ise.pubsub"); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query all sessions and stream process for ISE Session Directory service
*/
public class SessionQueryAll {
private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
private static class SessionQueryRequest {
OffsetDateTime startTimestamp;
}
private static void query(SampleConfiguration config) throws Exception {
OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query all sessions and stream process for ISE Session Directory service
*/
public class SessionQueryAll {
private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
private static class SessionQueryRequest {
OffsetDateTime startTimestamp;
}
private static void query(SampleConfiguration config) throws Exception {
OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service | Service[] services = pxgrid.serviceLookup("com.cisco.ise.session"); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader; | package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query all sessions and stream process for ISE Session Directory service
*/
public class SessionQueryAll {
private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
private static class SessionQueryRequest {
OffsetDateTime startTimestamp;
}
private static void query(SampleConfiguration config) throws Exception {
OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service
Service[] services = pxgrid.serviceLookup("com.cisco.ise.session");
if (services == null || services.length == 0) {
logger.warn("Service unavailabe");
return;
}
// Use first service
Service service = services[0];
String url = service.getProperties().get("restBaseUrl") + "/getSessions";
logger.info("url={}", url);
// pxGrid AccesssSecret for the node
String secret = pxgrid.getAccessSecret(service.getNodeName());
SessionQueryRequest request = new SessionQueryRequest();
request.startTimestamp = startTimestamp;
HttpsURLConnection https = SampleHelper.createHttpsURLConnection(url, config.getNodeName(), secret, config.getSSLContext().getSocketFactory());
postAndStreamPrint(https, request);
}
public static void postAndStreamPrint(HttpsURLConnection httpsConn, Object postObject) throws IOException { | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
package com.cisco.pxgrid.samples.ise;
/**
* Demonstrates how to query all sessions and stream process for ISE Session Directory service
*/
public class SessionQueryAll {
private static Logger logger = LoggerFactory.getLogger(SessionQueryAll.class);
private static class SessionQueryRequest {
OffsetDateTime startTimestamp;
}
private static void query(SampleConfiguration config) throws Exception {
OffsetDateTime startTimestamp = SampleHelper.promptDate("Enter start time (ex. '2015-01-31T13:00:00-07:00' or <enter> for no start time): ");
PxgridControl pxgrid = new PxgridControl(config);
// pxGrid ServiceLookup for session service
Service[] services = pxgrid.serviceLookup("com.cisco.ise.session");
if (services == null || services.length == 0) {
logger.warn("Service unavailabe");
return;
}
// Use first service
Service service = services[0];
String url = service.getProperties().get("restBaseUrl") + "/getSessions";
logger.info("url={}", url);
// pxGrid AccesssSecret for the node
String secret = pxgrid.getAccessSecret(service.getNodeName());
SessionQueryRequest request = new SessionQueryRequest();
request.startTimestamp = startTimestamp;
HttpsURLConnection https = SampleHelper.createHttpsURLConnection(url, config.getNodeName(), secret, config.getSSLContext().getSocketFactory());
postAndStreamPrint(https, request);
}
public static void postAndStreamPrint(HttpsURLConnection httpsConn, Object postObject) throws IOException { | Gson gson = new GsonBuilder().registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter()).create(); |
cisco-pxgrid/pxgrid-rest-ws | java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader; | int count = 0;
jreader.beginArray();
while (jreader.hasNext()) {
Session session = gson.fromJson(jreader, Session.class);
System.out.println("session=" + session);
count++;
}
System.out.println("count=" + count);
}
}
} else {
try (InputStream in = httpsConn.getErrorStream()) {
String content = IOUtils.toString(in, StandardCharsets.UTF_8);
System.out.println("Content: " + content);
}
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionQueryAll");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | // Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SampleHelper.java
// public static class OffsetDateTimeAdapter extends TypeAdapter<OffsetDateTime> {
// DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
//
// @Override
// public void write(JsonWriter out, OffsetDateTime value) throws IOException {
// if (value == null) {
// out.nullValue();
// return;
// }
// out.value(formatter.format(value));
// }
//
// @Override
// public OffsetDateTime read(JsonReader in) throws IOException {
// if (in.peek() == JsonToken.NULL) {
// in.nextNull();
// return null;
// }
// return formatter.parse(in.nextString(), OffsetDateTime::from);
// }
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/AccountState.java
// public enum AccountState {
// /**
// * The internal state when the account is created, but never connected.
// */
// INIT,
//
// /**
// * The state when the account is pending for approval from administrator
// */
// PENDING,
//
// /**
// * The state where all pxGrid control functionalities are available.
// */
// ENABLED,
//
// /**
// * A disabled account. Administrator can disable or enable the account.
// */
// DISABLED;
// }
//
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/model/Service.java
// public class Service {
// private String name;
// private String nodeName;
// private Map<String, String> properties;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getNodeName() {
// return nodeName;
// }
//
// public void setNodeName(String nodeName) {
// this.nodeName = nodeName;
// }
//
// public Map<String, String> getProperties() {
// return properties;
// }
//
// public void setProperties(Map<String, String> properties) {
// this.properties = properties;
// }
// }
// Path: java/src/main/java/com/cisco/pxgrid/samples/ise/SessionQueryAll.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cisco.pxgrid.samples.ise.SampleHelper.OffsetDateTimeAdapter;
import com.cisco.pxgrid.samples.ise.model.AccountState;
import com.cisco.pxgrid.samples.ise.model.Service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
int count = 0;
jreader.beginArray();
while (jreader.hasNext()) {
Session session = gson.fromJson(jreader, Session.class);
System.out.println("session=" + session);
count++;
}
System.out.println("count=" + count);
}
}
} else {
try (InputStream in = httpsConn.getErrorStream()) {
String content = IOUtils.toString(in, StandardCharsets.UTF_8);
System.out.println("Content: " + content);
}
}
}
public static void main(String [] args) throws Exception {
// Parse arguments
SampleConfiguration config = new SampleConfiguration();
try {
config.parse(args);
} catch (ParseException e) {
config.printHelp("SessionQueryAll");
System.exit(1);
}
// AccountActivate
PxgridControl control = new PxgridControl(config); | while (control.accountActivate() != AccountState.ENABLED) |
lukasz-kusek/xml-comparator | src/main/java/com/github/lukaszkusek/xml/comparator/document/XSLTransformer.java | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/util/ResourceReader.java
// public final class ResourceReader {
//
// private ResourceReader() {}
//
// public static String getFileContent(String fileName) throws IOException {
// return Resources.toString(getURL(fileName), Charsets.UTF_8);
// }
//
// public static InputStream getInputStream(final String fileName) throws IOException {
// return Resources.newInputStreamSupplier(getURL(fileName)).getInput();
// }
//
// public static URL getURL(final String fileName) {
// return Resources.getResource("com/github/lukaszkusek/xml/comparator/" + fileName);
// }
// }
| import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import com.github.lukaszkusek.xml.comparator.util.ResourceReader;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; | /*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.document;
class XSLTransformer {
private Templates templates;
XSLTransformer(String xslFileName) throws TransformerConfigurationException, IOException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setErrorListener(new XSLTransformerErrorListener());
templates = transformerFactory.newTemplates( | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/util/ResourceReader.java
// public final class ResourceReader {
//
// private ResourceReader() {}
//
// public static String getFileContent(String fileName) throws IOException {
// return Resources.toString(getURL(fileName), Charsets.UTF_8);
// }
//
// public static InputStream getInputStream(final String fileName) throws IOException {
// return Resources.newInputStreamSupplier(getURL(fileName)).getInput();
// }
//
// public static URL getURL(final String fileName) {
// return Resources.getResource("com/github/lukaszkusek/xml/comparator/" + fileName);
// }
// }
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/document/XSLTransformer.java
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import com.github.lukaszkusek.xml.comparator.util.ResourceReader;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.document;
class XSLTransformer {
private Templates templates;
XSLTransformer(String xslFileName) throws TransformerConfigurationException, IOException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setErrorListener(new XSLTransformerErrorListener());
templates = transformerFactory.newTemplates( | new StreamSource(ResourceReader.getInputStream(xslFileName))); |
lukasz-kusek/xml-comparator | src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostEntry.java | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
| import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails; | /*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostEntry {
private boolean assigned;
private boolean taken; | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostEntry.java
import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails;
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostEntry {
private boolean assigned;
private boolean taken; | private DifferenceDetails differenceDetails; |
lukasz-kusek/xml-comparator | src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostMatrix.java | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/minimum/MinimumCostAssignmentCalculator.java
// public interface MinimumCostAssignmentCalculator {
// CostMatrix getMinimumCostAssignment(CostMatrix childrenComparisonMatrix);
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/node/INode.java
// public interface INode {
//
// boolean isNull();
//
// }
| import com.github.lukaszkusek.xml.comparator.node.INode;
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import com.github.lukaszkusek.xml.comparator.comparators.children.cost.minimum.MinimumCostAssignmentCalculator;
import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails; | /*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostMatrix {
private ArrayTable<INode, INode, CostEntry> costMatrix;
private CostMatrix(Collection<INode> children1, Collection<INode> children2) {
costMatrix = ArrayTable.create(children1, children2);
}
public static CostMatrix create(Collection<INode> children1, Collection<INode> children2) {
return new CostMatrix(children1, children2);
}
| // Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/minimum/MinimumCostAssignmentCalculator.java
// public interface MinimumCostAssignmentCalculator {
// CostMatrix getMinimumCostAssignment(CostMatrix childrenComparisonMatrix);
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/node/INode.java
// public interface INode {
//
// boolean isNull();
//
// }
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostMatrix.java
import com.github.lukaszkusek.xml.comparator.node.INode;
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import com.github.lukaszkusek.xml.comparator.comparators.children.cost.minimum.MinimumCostAssignmentCalculator;
import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails;
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostMatrix {
private ArrayTable<INode, INode, CostEntry> costMatrix;
private CostMatrix(Collection<INode> children1, Collection<INode> children2) {
costMatrix = ArrayTable.create(children1, children2);
}
public static CostMatrix create(Collection<INode> children1, Collection<INode> children2) {
return new CostMatrix(children1, children2);
}
| public void findMinimumCostAssignment(MinimumCostAssignmentCalculator minimumCostAssignmentCalculator) { |
lukasz-kusek/xml-comparator | src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostMatrix.java | // Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/minimum/MinimumCostAssignmentCalculator.java
// public interface MinimumCostAssignmentCalculator {
// CostMatrix getMinimumCostAssignment(CostMatrix childrenComparisonMatrix);
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/node/INode.java
// public interface INode {
//
// boolean isNull();
//
// }
| import com.github.lukaszkusek.xml.comparator.node.INode;
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import com.github.lukaszkusek.xml.comparator.comparators.children.cost.minimum.MinimumCostAssignmentCalculator;
import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails; | /*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostMatrix {
private ArrayTable<INode, INode, CostEntry> costMatrix;
private CostMatrix(Collection<INode> children1, Collection<INode> children2) {
costMatrix = ArrayTable.create(children1, children2);
}
public static CostMatrix create(Collection<INode> children1, Collection<INode> children2) {
return new CostMatrix(children1, children2);
}
public void findMinimumCostAssignment(MinimumCostAssignmentCalculator minimumCostAssignmentCalculator) {
merge(minimumCostAssignmentCalculator.getMinimumCostAssignment(this));
}
public CostMatrix merge(CostMatrix costMatrix) {
costMatrix.getCellSet()
.forEach(cell -> this.costMatrix.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue()));
return this;
}
| // Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/minimum/MinimumCostAssignmentCalculator.java
// public interface MinimumCostAssignmentCalculator {
// CostMatrix getMinimumCostAssignment(CostMatrix childrenComparisonMatrix);
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/diff/DifferenceDetails.java
// public class DifferenceDetails {
//
// private Set<DifferenceInformation> differenceInformationSet;
// private Set<DifferenceInformation> uniqueDifferenceInformationSet;
//
// public DifferenceDetails() {
// differenceInformationSet = Sets.newHashSet();
// uniqueDifferenceInformationSet = Sets.newHashSet();
// }
//
// public static DifferenceDetails empty() {
// return new DifferenceDetails();
// }
//
// public static DifferenceDetails of(Node node1, Node node2, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, DifferenceCode differenceCode) {
// put(node1, node2, null, differenceCode);
//
// return this;
// }
//
// public static DifferenceDetails of(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// DifferenceDetails differenceDetails = new DifferenceDetails();
// differenceDetails.put(node1, node2, attributeName, differenceCode);
//
// return differenceDetails;
// }
//
// public DifferenceDetails put(Node node1, Node node2, String attributeName, DifferenceCode differenceCode) {
// differenceInformationSet.add(new DifferenceInformation(node1, node2, attributeName, differenceCode));
// uniqueDifferenceInformationSet.add(
// new DifferenceInformation(
// Optional.ofNullable(node1).map(SimpleXPathNode::new).orElse(null),
// Optional.ofNullable(node2).map(SimpleXPathNode::new).orElse(null),
// attributeName,
// differenceCode));
//
// return this;
// }
//
// public DifferenceDetails putAll(DifferenceDetails differenceDetails) {
// this.differenceInformationSet.addAll(differenceDetails.getDifferenceInformationSet());
// this.uniqueDifferenceInformationSet.addAll(differenceDetails.getUniqueDifferenceInformationSet());
//
// return this;
// }
//
// public Set<DifferenceInformation> getDifferenceInformationSet() {
// return differenceInformationSet;
// }
//
// public void setDifferenceInformationSet(Set<DifferenceInformation> differenceInformationSet) {
// this.differenceInformationSet = differenceInformationSet;
// }
//
// public Set<DifferenceInformation> getUniqueDifferenceInformationSet() {
// return uniqueDifferenceInformationSet;
// }
//
// public void setUniqueDifferenceInformationSet(Set<DifferenceInformation> uniqueDifferenceInformationSet) {
// this.uniqueDifferenceInformationSet = uniqueDifferenceInformationSet;
// }
//
// public DifferenceDetails filter(Predicate<DifferenceInformation> xPathsToOmitPredicate) {
// DifferenceDetails filteredDifferenceDetails = new DifferenceDetails();
//
// filteredDifferenceDetails.setUniqueDifferenceInformationSet(
// filter(getUniqueDifferenceInformationSet(), xPathsToOmitPredicate));
//
// filteredDifferenceDetails.setDifferenceInformationSet(
// filter(getDifferenceInformationSet(), xPathsToOmitPredicate));
//
// return filteredDifferenceDetails;
// }
//
// private Set<DifferenceInformation> filter(
// Set<DifferenceInformation> differenceInformationSet, Predicate<DifferenceInformation> xPathsToOmitPredicate) {
//
// return differenceInformationSet.stream().filter(xPathsToOmitPredicate).collect(Collectors.toSet());
// }
//
// public int getCount() {
// return differenceInformationSet.size();
// }
//
// public boolean isBestMatch() {
// return getCount() == 0;
// }
// }
//
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/node/INode.java
// public interface INode {
//
// boolean isNull();
//
// }
// Path: src/main/java/com/github/lukaszkusek/xml/comparator/comparators/children/cost/CostMatrix.java
import com.github.lukaszkusek.xml.comparator.node.INode;
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import com.github.lukaszkusek.xml.comparator.comparators.children.cost.minimum.MinimumCostAssignmentCalculator;
import com.github.lukaszkusek.xml.comparator.diff.DifferenceDetails;
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Lukasz Kusek
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.lukaszkusek.xml.comparator.comparators.children.cost;
public class CostMatrix {
private ArrayTable<INode, INode, CostEntry> costMatrix;
private CostMatrix(Collection<INode> children1, Collection<INode> children2) {
costMatrix = ArrayTable.create(children1, children2);
}
public static CostMatrix create(Collection<INode> children1, Collection<INode> children2) {
return new CostMatrix(children1, children2);
}
public void findMinimumCostAssignment(MinimumCostAssignmentCalculator minimumCostAssignmentCalculator) {
merge(minimumCostAssignmentCalculator.getMinimumCostAssignment(this));
}
public CostMatrix merge(CostMatrix costMatrix) {
costMatrix.getCellSet()
.forEach(cell -> this.costMatrix.put(cell.getRowKey(), cell.getColumnKey(), cell.getValue()));
return this;
}
| public void put(INode child1, INode child2, DifferenceDetails differenceDetails) { |
scp504677840/ExcellentWiFi | src/com/jzlg/excellentwifi/activity/BaseActivity.java | // Path: src/com/jzlg/excellentwifi/utils/ActivityCollector.java
// public class ActivityCollector {
// public static List<Activity> activities = new ArrayList<Activity>();
//
// /**
// * Ìí¼Ó»î¶¯
// *
// * @param activity
// * »î¶¯
// */
// public static void addActivity(Activity activity) {
// activities.add(activity);
// }
//
// /**
// * Çå³ýÒ»¸ö»î¶¯
// *
// * @param activity
// * »î¶¯
// */
// public static void removeActivity(Activity activity) {
// activities.remove(activity);
// }
//
// /**
// * Ïú»ÙËùÓл
// */
// public static void finishAll() {
// for (Activity activity : activities) {
// if (!activity.isFinishing()) {
// activity.finish();
// }
// }
// }
//
// }
| import com.jzlg.excellentwifi.utils.ActivityCollector;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Window;
import android.widget.Toast; | package com.jzlg.excellentwifi.activity;
/**
* Activity»ùÀà
*
* @author ËδºÅô
*
*/
public class BaseActivity extends FragmentActivity {
private long time = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Òþ²Ø±êÌâÀ¸
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// »ñÈ¡µ±Ç°ÊµÀýµÄÀàÃû
Log.i("BaseActivity", getClass().getSimpleName()); | // Path: src/com/jzlg/excellentwifi/utils/ActivityCollector.java
// public class ActivityCollector {
// public static List<Activity> activities = new ArrayList<Activity>();
//
// /**
// * Ìí¼Ó»î¶¯
// *
// * @param activity
// * »î¶¯
// */
// public static void addActivity(Activity activity) {
// activities.add(activity);
// }
//
// /**
// * Çå³ýÒ»¸ö»î¶¯
// *
// * @param activity
// * »î¶¯
// */
// public static void removeActivity(Activity activity) {
// activities.remove(activity);
// }
//
// /**
// * Ïú»ÙËùÓл
// */
// public static void finishAll() {
// for (Activity activity : activities) {
// if (!activity.isFinishing()) {
// activity.finish();
// }
// }
// }
//
// }
// Path: src/com/jzlg/excellentwifi/activity/BaseActivity.java
import com.jzlg.excellentwifi.utils.ActivityCollector;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Window;
import android.widget.Toast;
package com.jzlg.excellentwifi.activity;
/**
* Activity»ùÀà
*
* @author ËδºÅô
*
*/
public class BaseActivity extends FragmentActivity {
private long time = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Òþ²Ø±êÌâÀ¸
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// »ñÈ¡µ±Ç°ÊµÀýµÄÀàÃû
Log.i("BaseActivity", getClass().getSimpleName()); | ActivityCollector.addActivity(this); |
izenecloud/laser | src/main/java/io/izenecloud/lr/LrIterationMapContext.java | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
| import io.izenecloud.larser.feature.OnlineVectorWritable;
import org.apache.mahout.math.Vector; | package io.izenecloud.lr;
public class LrIterationMapContext {
private static final double LAMBDA_VALUE = 1e-6;
private Vector[] a;
private double[] b;
private double[] knownOffset;
private double[] x;
private double rho;
private double lambdaValue;
| // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
// Path: src/main/java/io/izenecloud/lr/LrIterationMapContext.java
import io.izenecloud.larser.feature.OnlineVectorWritable;
import org.apache.mahout.math.Vector;
package io.izenecloud.lr;
public class LrIterationMapContext {
private static final double LAMBDA_VALUE = 1e-6;
private Vector[] a;
private double[] b;
private double[] knownOffset;
private double[] x;
private double rho;
private double lambdaValue;
| public LrIterationMapContext(OnlineVectorWritable[] ab) { |
izenecloud/laser | src/main/java/io/izenecloud/lr/LrIterationDriver.java | // Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
| import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; | package io.izenecloud.lr;
public class LrIterationDriver {
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
if (null != addIntercept) {
conf.setBoolean("lr.iteration.add.intercept", addIntercept);
}
if (null != regularizationFactor) {
conf.setDouble("lr.iteration.regulariztion.factor",
regularizationFactor);
}
conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
Job job = Job.getInstance(conf);
job.setJarByClass(LrIterationDriver.class);
job.setJobName("logistic regression");
FileInputFormat.setInputPaths(job, input);
| // Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
package io.izenecloud.lr;
public class LrIterationDriver {
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
if (null != addIntercept) {
conf.setBoolean("lr.iteration.add.intercept", addIntercept);
}
if (null != regularizationFactor) {
conf.setDouble("lr.iteration.regulariztion.factor",
regularizationFactor);
}
conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
Job job = Job.getInstance(conf);
job.setJarByClass(LrIterationDriver.class);
job.setJobName("logistic regression");
FileInputFormat.setInputPaths(job, input);
| job.setOutputFormatClass(MsgpackOutputFormat.class); |
izenecloud/laser | src/test/java/io/izenecloud/larser/feature/TestUserProfileHelper.java | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
| import io.izenecloud.conf.Configuration;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.*; | package io.izenecloud.larser.feature;
public class TestUserProfileHelper {
private static final String PROPERTIES = "src/test/properties/laser.properties.examble";
@BeforeTest
public void setup() throws IOException {
Path pro = new Path(PROPERTIES); | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
// Path: src/test/java/io/izenecloud/larser/feature/TestUserProfileHelper.java
import io.izenecloud.conf.Configuration;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
package io.izenecloud.larser.feature;
public class TestUserProfileHelper {
private static final String PROPERTIES = "src/test/properties/laser.properties.examble";
@BeforeTest
public void setup() throws IOException {
Path pro = new Path(PROPERTIES); | org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); |
izenecloud/laser | src/main/java/io/izenecloud/larser/feature/webscale/AdInfo.java | // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
| import io.izenecloud.msgpack.SparseVector;
import org.msgpack.annotation.Message; | package io.izenecloud.larser.feature.webscale;
@Message
class AdInfo {
public String DOCID;
public String clusteringId; | // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
// Path: src/main/java/io/izenecloud/larser/feature/webscale/AdInfo.java
import io.izenecloud.msgpack.SparseVector;
import org.msgpack.annotation.Message;
package io.izenecloud.larser.feature.webscale;
@Message
class AdInfo {
public String DOCID;
public String clusteringId; | public SparseVector context; |
izenecloud/laser | src/main/java/io/izenecloud/lr/LrIterationMapper.java | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
| import io.izenecloud.larser.feature.OnlineVectorWritable;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Mapper;
import edu.stanford.nlp.optimization.QNMinimizer; | package io.izenecloud.lr;
public class LrIterationMapper extends
Mapper<Text, ListWritable, String, LaserOnlineModel> {
private static final double DEFAULT_REGULARIZATION_FACTOR = 0.000001f;
private double regularizationFactor;
private QNMinimizer lbfgs;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
regularizationFactor = conf.getDouble(
"lr.iteration.regulariztion.factor",
DEFAULT_REGULARIZATION_FACTOR);
lbfgs = new QNMinimizer();
lbfgs.setRobustOptions();
}
protected void map(Text key, ListWritable valueWritable, Context context)
throws IOException, InterruptedException { | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
// Path: src/main/java/io/izenecloud/lr/LrIterationMapper.java
import io.izenecloud.larser.feature.OnlineVectorWritable;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.Mapper;
import edu.stanford.nlp.optimization.QNMinimizer;
package io.izenecloud.lr;
public class LrIterationMapper extends
Mapper<Text, ListWritable, String, LaserOnlineModel> {
private static final double DEFAULT_REGULARIZATION_FACTOR = 0.000001f;
private double regularizationFactor;
private QNMinimizer lbfgs;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
regularizationFactor = conf.getDouble(
"lr.iteration.regulariztion.factor",
DEFAULT_REGULARIZATION_FACTOR);
lbfgs = new QNMinimizer();
lbfgs.setRobustOptions();
}
protected void map(Text key, ListWritable valueWritable, Context context)
throws IOException, InterruptedException { | OnlineVectorWritable[] inputSplitData = new OnlineVectorWritable[valueWritable |
izenecloud/laser | src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainer.java | // Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
// public class OnlineFeatureDriver {
// private static final Logger LOG = LoggerFactory
// .getLogger(OnlineFeatureDriver.class);
//
// public static long run(String collection, Path input, Path output,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// Job job = Job.getInstance(conf);
//
// job.setJarByClass(OnlineFeatureDriver.class);
// job.setJobName("GROUP each record's feature BY identifier");
//
// FileInputFormat.setInputPaths(job, input);
// FileOutputFormat.setOutputPath(job, output);
//
// job.setInputFormatClass(SequenceFileInputFormat.class);
// job.setOutputFormatClass(SequenceFileOutputFormat.class);
//
// job.setMapOutputKeyClass(Text.class);
// job.setMapOutputValueClass(OnlineVectorWritable.class);
// job.setOutputKeyClass(Text.class);
// job.setOutputValueClass(ListWritable.class);
//
// job.setMapperClass(OnlineFeatureMapper.class);
// job.setReducerClass(OnlineFeatureReducer.class);
//
// HadoopUtil.delete(conf, output);
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:Group feature, Failed!");
// }
// Counter counter = job.getCounters().findCounter(
// "org.apache.hadoop.mapred.Task$Counter",
// "REDUCE_OUTPUT_RECORDS");
// long reduceOutputRecords = counter.getValue();
//
// LOG.info(
// "Job: GROUP each record's feature BY identifier, output recordes = {}",
// reduceOutputRecords);
//
// return reduceOutputRecords;
// }
// }
//
// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
// public class LrIterationDriver {
// public static int run(String collection, Path input, Path output,
// Float regularizationFactor, Boolean addIntercept,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// if (null != addIntercept) {
// conf.setBoolean("lr.iteration.add.intercept", addIntercept);
// }
// if (null != regularizationFactor) {
// conf.setDouble("lr.iteration.regulariztion.factor",
// regularizationFactor);
// }
//
// conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
//
// Job job = Job.getInstance(conf);
// job.setJarByClass(LrIterationDriver.class);
// job.setJobName("logistic regression");
//
// FileInputFormat.setInputPaths(job, input);
//
// job.setOutputFormatClass(MsgpackOutputFormat.class);
// job.setOutputKeyClass(String.class);
// job.setOutputValueClass(LaserOnlineModel.class);
//
// LrIterationInputFormat.setNumMapTasks(job, 120);
// job.setInputFormatClass(LrIterationInputFormat.class);
// job.setMapperClass(LrIterationMapper.class);
// job.setNumReduceTasks(0);
//
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:logistic regression, Failed!");
// }
// return 0;
// }
// }
| import io.izenecloud.larser.feature.online.OnlineFeatureDriver;
import io.izenecloud.lr.LrIterationDriver;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package io.izenecloud.larser.online;
public class LaserOnlineModelTrainer {
private static final Logger LOG = LoggerFactory
.getLogger(LaserOnlineModelTrainer.class);
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept, Configuration conf)
throws ClassNotFoundException, IOException, InterruptedException {
Path groupByIdendifier = new Path(output, "groupByIdendifier");
try { | // Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
// public class OnlineFeatureDriver {
// private static final Logger LOG = LoggerFactory
// .getLogger(OnlineFeatureDriver.class);
//
// public static long run(String collection, Path input, Path output,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// Job job = Job.getInstance(conf);
//
// job.setJarByClass(OnlineFeatureDriver.class);
// job.setJobName("GROUP each record's feature BY identifier");
//
// FileInputFormat.setInputPaths(job, input);
// FileOutputFormat.setOutputPath(job, output);
//
// job.setInputFormatClass(SequenceFileInputFormat.class);
// job.setOutputFormatClass(SequenceFileOutputFormat.class);
//
// job.setMapOutputKeyClass(Text.class);
// job.setMapOutputValueClass(OnlineVectorWritable.class);
// job.setOutputKeyClass(Text.class);
// job.setOutputValueClass(ListWritable.class);
//
// job.setMapperClass(OnlineFeatureMapper.class);
// job.setReducerClass(OnlineFeatureReducer.class);
//
// HadoopUtil.delete(conf, output);
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:Group feature, Failed!");
// }
// Counter counter = job.getCounters().findCounter(
// "org.apache.hadoop.mapred.Task$Counter",
// "REDUCE_OUTPUT_RECORDS");
// long reduceOutputRecords = counter.getValue();
//
// LOG.info(
// "Job: GROUP each record's feature BY identifier, output recordes = {}",
// reduceOutputRecords);
//
// return reduceOutputRecords;
// }
// }
//
// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
// public class LrIterationDriver {
// public static int run(String collection, Path input, Path output,
// Float regularizationFactor, Boolean addIntercept,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// if (null != addIntercept) {
// conf.setBoolean("lr.iteration.add.intercept", addIntercept);
// }
// if (null != regularizationFactor) {
// conf.setDouble("lr.iteration.regulariztion.factor",
// regularizationFactor);
// }
//
// conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
//
// Job job = Job.getInstance(conf);
// job.setJarByClass(LrIterationDriver.class);
// job.setJobName("logistic regression");
//
// FileInputFormat.setInputPaths(job, input);
//
// job.setOutputFormatClass(MsgpackOutputFormat.class);
// job.setOutputKeyClass(String.class);
// job.setOutputValueClass(LaserOnlineModel.class);
//
// LrIterationInputFormat.setNumMapTasks(job, 120);
// job.setInputFormatClass(LrIterationInputFormat.class);
// job.setMapperClass(LrIterationMapper.class);
// job.setNumReduceTasks(0);
//
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:logistic regression, Failed!");
// }
// return 0;
// }
// }
// Path: src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainer.java
import io.izenecloud.larser.feature.online.OnlineFeatureDriver;
import io.izenecloud.lr.LrIterationDriver;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package io.izenecloud.larser.online;
public class LaserOnlineModelTrainer {
private static final Logger LOG = LoggerFactory
.getLogger(LaserOnlineModelTrainer.class);
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept, Configuration conf)
throws ClassNotFoundException, IOException, InterruptedException {
Path groupByIdendifier = new Path(output, "groupByIdendifier");
try { | if (0 == OnlineFeatureDriver.run(collection, input, groupByIdendifier, conf)) { |
izenecloud/laser | src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainer.java | // Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
// public class OnlineFeatureDriver {
// private static final Logger LOG = LoggerFactory
// .getLogger(OnlineFeatureDriver.class);
//
// public static long run(String collection, Path input, Path output,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// Job job = Job.getInstance(conf);
//
// job.setJarByClass(OnlineFeatureDriver.class);
// job.setJobName("GROUP each record's feature BY identifier");
//
// FileInputFormat.setInputPaths(job, input);
// FileOutputFormat.setOutputPath(job, output);
//
// job.setInputFormatClass(SequenceFileInputFormat.class);
// job.setOutputFormatClass(SequenceFileOutputFormat.class);
//
// job.setMapOutputKeyClass(Text.class);
// job.setMapOutputValueClass(OnlineVectorWritable.class);
// job.setOutputKeyClass(Text.class);
// job.setOutputValueClass(ListWritable.class);
//
// job.setMapperClass(OnlineFeatureMapper.class);
// job.setReducerClass(OnlineFeatureReducer.class);
//
// HadoopUtil.delete(conf, output);
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:Group feature, Failed!");
// }
// Counter counter = job.getCounters().findCounter(
// "org.apache.hadoop.mapred.Task$Counter",
// "REDUCE_OUTPUT_RECORDS");
// long reduceOutputRecords = counter.getValue();
//
// LOG.info(
// "Job: GROUP each record's feature BY identifier, output recordes = {}",
// reduceOutputRecords);
//
// return reduceOutputRecords;
// }
// }
//
// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
// public class LrIterationDriver {
// public static int run(String collection, Path input, Path output,
// Float regularizationFactor, Boolean addIntercept,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// if (null != addIntercept) {
// conf.setBoolean("lr.iteration.add.intercept", addIntercept);
// }
// if (null != regularizationFactor) {
// conf.setDouble("lr.iteration.regulariztion.factor",
// regularizationFactor);
// }
//
// conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
//
// Job job = Job.getInstance(conf);
// job.setJarByClass(LrIterationDriver.class);
// job.setJobName("logistic regression");
//
// FileInputFormat.setInputPaths(job, input);
//
// job.setOutputFormatClass(MsgpackOutputFormat.class);
// job.setOutputKeyClass(String.class);
// job.setOutputValueClass(LaserOnlineModel.class);
//
// LrIterationInputFormat.setNumMapTasks(job, 120);
// job.setInputFormatClass(LrIterationInputFormat.class);
// job.setMapperClass(LrIterationMapper.class);
// job.setNumReduceTasks(0);
//
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:logistic regression, Failed!");
// }
// return 0;
// }
// }
| import io.izenecloud.larser.feature.online.OnlineFeatureDriver;
import io.izenecloud.lr.LrIterationDriver;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package io.izenecloud.larser.online;
public class LaserOnlineModelTrainer {
private static final Logger LOG = LoggerFactory
.getLogger(LaserOnlineModelTrainer.class);
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept, Configuration conf)
throws ClassNotFoundException, IOException, InterruptedException {
Path groupByIdendifier = new Path(output, "groupByIdendifier");
try {
if (0 == OnlineFeatureDriver.run(collection, input, groupByIdendifier, conf)) {
return 0;
}
} catch (IllegalStateException e) {
LOG.error("the online feature generate phase failed, "
+ e.getMessage());
throw e;
}
conf.setInt("mapred.task.timeout", 6000000);
Path lrOutput = new Path(output, "LR"); | // Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
// public class OnlineFeatureDriver {
// private static final Logger LOG = LoggerFactory
// .getLogger(OnlineFeatureDriver.class);
//
// public static long run(String collection, Path input, Path output,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// Job job = Job.getInstance(conf);
//
// job.setJarByClass(OnlineFeatureDriver.class);
// job.setJobName("GROUP each record's feature BY identifier");
//
// FileInputFormat.setInputPaths(job, input);
// FileOutputFormat.setOutputPath(job, output);
//
// job.setInputFormatClass(SequenceFileInputFormat.class);
// job.setOutputFormatClass(SequenceFileOutputFormat.class);
//
// job.setMapOutputKeyClass(Text.class);
// job.setMapOutputValueClass(OnlineVectorWritable.class);
// job.setOutputKeyClass(Text.class);
// job.setOutputValueClass(ListWritable.class);
//
// job.setMapperClass(OnlineFeatureMapper.class);
// job.setReducerClass(OnlineFeatureReducer.class);
//
// HadoopUtil.delete(conf, output);
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:Group feature, Failed!");
// }
// Counter counter = job.getCounters().findCounter(
// "org.apache.hadoop.mapred.Task$Counter",
// "REDUCE_OUTPUT_RECORDS");
// long reduceOutputRecords = counter.getValue();
//
// LOG.info(
// "Job: GROUP each record's feature BY identifier, output recordes = {}",
// reduceOutputRecords);
//
// return reduceOutputRecords;
// }
// }
//
// Path: src/main/java/io/izenecloud/lr/LrIterationDriver.java
// public class LrIterationDriver {
// public static int run(String collection, Path input, Path output,
// Float regularizationFactor, Boolean addIntercept,
// Configuration baseConf) throws IOException, ClassNotFoundException,
// InterruptedException {
// Configuration conf = new Configuration(baseConf);
// if (null != addIntercept) {
// conf.setBoolean("lr.iteration.add.intercept", addIntercept);
// }
// if (null != regularizationFactor) {
// conf.setDouble("lr.iteration.regulariztion.factor",
// regularizationFactor);
// }
//
// conf.set("com.b5m.laser.msgpack.output.method", "update_online_model");
//
// Job job = Job.getInstance(conf);
// job.setJarByClass(LrIterationDriver.class);
// job.setJobName("logistic regression");
//
// FileInputFormat.setInputPaths(job, input);
//
// job.setOutputFormatClass(MsgpackOutputFormat.class);
// job.setOutputKeyClass(String.class);
// job.setOutputValueClass(LaserOnlineModel.class);
//
// LrIterationInputFormat.setNumMapTasks(job, 120);
// job.setInputFormatClass(LrIterationInputFormat.class);
// job.setMapperClass(LrIterationMapper.class);
// job.setNumReduceTasks(0);
//
// boolean succeeded = job.waitForCompletion(true);
// if (!succeeded) {
// throw new IllegalStateException("Job:logistic regression, Failed!");
// }
// return 0;
// }
// }
// Path: src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainer.java
import io.izenecloud.larser.feature.online.OnlineFeatureDriver;
import io.izenecloud.lr.LrIterationDriver;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package io.izenecloud.larser.online;
public class LaserOnlineModelTrainer {
private static final Logger LOG = LoggerFactory
.getLogger(LaserOnlineModelTrainer.class);
public static int run(String collection, Path input, Path output,
Float regularizationFactor, Boolean addIntercept, Configuration conf)
throws ClassNotFoundException, IOException, InterruptedException {
Path groupByIdendifier = new Path(output, "groupByIdendifier");
try {
if (0 == OnlineFeatureDriver.run(collection, input, groupByIdendifier, conf)) {
return 0;
}
} catch (IllegalStateException e) {
LOG.error("the online feature generate phase failed, "
+ e.getMessage());
throw e;
}
conf.setInt("mapred.task.timeout", 6000000);
Path lrOutput = new Path(output, "LR"); | LrIterationDriver.run(collection, groupByIdendifier, lrOutput, |
izenecloud/laser | src/main/java/io/izenecloud/msgpack/PriorityQueue.java | // Path: src/main/java/io/izenecloud/larser/offline/topn/IntDoublePairWritable.java
// public class IntDoublePairWritable implements
// WritableComparable<IntDoublePairWritable> {
//
// private int key;
// private double value;
//
// public IntDoublePairWritable() {
// }
//
// public IntDoublePairWritable(int k, double v) {
// this.key = k;
// this.value = v;
// }
//
// public void setKey(int k) {
// this.key = k;
// }
//
// public void setValue(double v) {
// this.value = v;
// }
//
// public void readFields(DataInput in) throws IOException {
// this.key = in.readInt();
// this.value = in.readDouble();
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeInt(key);
// out.writeDouble(value);
// }
//
// public int getKey() {
// return key;
// }
//
// public double getValue() {
// return value;
// }
//
// public int compareTo(IntDoublePairWritable o) {
// if (this.value > o.value) {
// return 1;
// } else if (this.value < o.value) {
// return -1;
// }
// return 0;
// }
// }
| import io.izenecloud.larser.offline.topn.IntDoublePairWritable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.msgpack.annotation.Message; | package io.izenecloud.msgpack;
@Message
public class PriorityQueue {
private String user;
private Map<Integer, Float> cluster;
public PriorityQueue() {
}
public PriorityQueue(String user,
io.izenecloud.larser.offline.topn.PriorityQueue queue) {
this.user = user;
this.cluster = new HashMap<Integer, Float>(); | // Path: src/main/java/io/izenecloud/larser/offline/topn/IntDoublePairWritable.java
// public class IntDoublePairWritable implements
// WritableComparable<IntDoublePairWritable> {
//
// private int key;
// private double value;
//
// public IntDoublePairWritable() {
// }
//
// public IntDoublePairWritable(int k, double v) {
// this.key = k;
// this.value = v;
// }
//
// public void setKey(int k) {
// this.key = k;
// }
//
// public void setValue(double v) {
// this.value = v;
// }
//
// public void readFields(DataInput in) throws IOException {
// this.key = in.readInt();
// this.value = in.readDouble();
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeInt(key);
// out.writeDouble(value);
// }
//
// public int getKey() {
// return key;
// }
//
// public double getValue() {
// return value;
// }
//
// public int compareTo(IntDoublePairWritable o) {
// if (this.value > o.value) {
// return 1;
// } else if (this.value < o.value) {
// return -1;
// }
// return 0;
// }
// }
// Path: src/main/java/io/izenecloud/msgpack/PriorityQueue.java
import io.izenecloud.larser.offline.topn.IntDoublePairWritable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.msgpack.annotation.Message;
package io.izenecloud.msgpack;
@Message
public class PriorityQueue {
private String user;
private Map<Integer, Float> cluster;
public PriorityQueue() {
}
public PriorityQueue(String user,
io.izenecloud.larser.offline.topn.PriorityQueue queue) {
this.user = user;
this.cluster = new HashMap<Integer, Float>(); | Iterator<IntDoublePairWritable> iterator = queue.iterator(); |
izenecloud/laser | src/test/java/io/izenecloud/couchbase/CouchbaseInputFormatIT.java | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
| import io.izenecloud.conf.Configuration;
import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.*; | package io.izenecloud.couchbase;
public class CouchbaseInputFormatIT {
private static final String PROPERTIES = "src/test/properties/laser.properties.examble"; | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
// Path: src/test/java/io/izenecloud/couchbase/CouchbaseInputFormatIT.java
import io.izenecloud.conf.Configuration;
import java.io.IOException;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
package io.izenecloud.couchbase;
public class CouchbaseInputFormatIT {
private static final String PROPERTIES = "src/test/properties/laser.properties.examble"; | private org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); |
izenecloud/laser | src/main/java/io/izenecloud/metaq/Consumer.java | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
| import io.izenecloud.conf.Configuration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import com.taobao.metamorphosis.client.MessageSessionFactory;
import com.taobao.metamorphosis.client.MetaClientConfig;
import com.taobao.metamorphosis.client.MetaMessageSessionFactory;
import com.taobao.metamorphosis.client.consumer.ConsumerConfig;
import com.taobao.metamorphosis.client.consumer.MessageConsumer;
import com.taobao.metamorphosis.client.consumer.MessageListener;
import com.taobao.metamorphosis.exception.MetaClientException;
import com.taobao.metamorphosis.utils.ZkUtils.ZKConfig; | package io.izenecloud.metaq;
public class Consumer {
private static Consumer metaqConsumer = null;
public static synchronized Consumer getInstance()
throws MetaClientException {
if (null == metaqConsumer) {
metaqConsumer = new Consumer();
}
return metaqConsumer;
}
private final Map<String, MessageConsumer> consumer;
public Consumer() {
consumer = new HashMap<String, MessageConsumer>();
}
public void subscribe(String collection, MessageListener listener)
throws MetaClientException { | // Path: src/main/java/io/izenecloud/conf/Configuration.java
// public class Configuration {
//
// private static Configuration conf = null;
//
// public static synchronized Configuration getInstance() {
// if (null == conf) {
// conf = new Configuration();
// }
// return conf;
// }
//
// public synchronized void load(Path path, FileSystem fs) throws IOException {
// final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
// FileStatus[] fileStatus = fs.listStatus(path, new GlobFilter(
// "*.properties"));
// for (FileStatus file : fileStatus) {
// if (file.isFile()) {
// Path p = file.getPath();
// FSDataInputStream in = fs.open(p);
// Collection configuration = OBJECT_MAPPER.readValue(in,
// Collection.class);
// String collection = p.getName().substring(0,
// p.getName().lastIndexOf(".properties"));
// configuration.setCollecion(collection);
// mapper.put(collection, configuration);
// }
// }
// }
//
// private Map<String, Collection> mapper = new HashMap<String, Collection>();
//
// public List<String> getCollections() {
// List<String> collectionList = new ArrayList<String>();
// Iterator<Map.Entry<String, Collection>> iterator = mapper.entrySet()
// .iterator();
// while (iterator.hasNext()) {
// String collection = iterator.next().getKey();
// collectionList.add(collection);
// }
// return collectionList;
// }
//
// public void removeCollection(String collection) {
// mapper.remove(collection);
// }
//
// public Class<? extends LaserMessageConsumer> getMessageConsumer(
// String collection) throws ClassNotFoundException {
// return getCollection(collection).getMessageConsumer();
// }
//
// public Path getLaserHDFSRoot(String collection) {
// return getCollection(collection).getLaserHDFSRoot();
//
// }
//
// public String getCouchbaseCluster(String collection) {
// return getCollection(collection).getCouchbaseCluster();
// }
//
// public String getCouchbaseBucket(String collection) {
// return getCollection(collection).getCouchbaseBucket();
//
// }
//
// public String getCouchbasePassword(String collection) {
// return getCollection(collection).getCouchbasePassword();
// }
//
// public String getMetaqZookeeper(String collection) {
// return getCollection(collection).getMetaqZookeeper();
// }
//
// public String getMetaqTopic(String collection) {
// return getCollection(collection).getMetaqTopic();
// }
//
// public Path getMetaqOutput(String collection) {
// return getCollection(collection).getMetaqOutput();
//
// }
//
// public Path getLaserOnlineOutput(String collection) {
// return getCollection(collection).getLaserOnlineOutput();
// }
//
// public Path getLaserOfflineOutput(String collection) {
// return getCollection(collection).getLaserOfflineOutput();
// }
//
// public String getLaserOnlineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOnlineRetrainingFreqency();
// }
//
// public String getLaserOfflineRetrainingFreqency(String collection) {
// return getCollection(collection).getLaserOfflineRetrainingFreqency();
// }
//
// public Integer getUserFeatureDimension(String collection) {
// return getCollection(collection).getUserFeatureDimension();
// }
//
// public Path getUserFeatureSerializePath(String collection) {
// return getCollection(collection).getUserFeatureSerializePath();
// }
//
// public Integer getItemFeatureDimension(String collection) {
// return getCollection(collection).getItemFeatureDimension();
// }
//
// public Integer getTopNClustering(String collection) {
// return getCollection(collection).getTopNClustering();
// }
//
// public Float getRegularizationFactor(String collection) {
// return getCollection(collection).getRegularizationFactor();
// }
//
// public Boolean addIntercept(String collection) {
// return getCollection(collection).addIntercept();
// }
//
// public Integer getMaxIteration(String collection) {
// return getCollection(collection).getMaxIteration();
// }
//
// public String getMsgpackAddress(String collection) {
// return getCollection(collection).getMsgpackAddress();
// }
//
// public Integer getMsgpackPort(String collection) {
// return getCollection(collection).getMsgpackPort();
// }
//
// private Collection getCollection(String collection) {
// return mapper.get(collection);
// }
//
// private String getProperty(Map<String, Map<String, String>> collection,
// String property, String propertyName) {
// return collection.get(property).get(propertyName);
// }
// }
// Path: src/main/java/io/izenecloud/metaq/Consumer.java
import io.izenecloud.conf.Configuration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import com.taobao.metamorphosis.client.MessageSessionFactory;
import com.taobao.metamorphosis.client.MetaClientConfig;
import com.taobao.metamorphosis.client.MetaMessageSessionFactory;
import com.taobao.metamorphosis.client.consumer.ConsumerConfig;
import com.taobao.metamorphosis.client.consumer.MessageConsumer;
import com.taobao.metamorphosis.client.consumer.MessageListener;
import com.taobao.metamorphosis.exception.MetaClientException;
import com.taobao.metamorphosis.utils.ZkUtils.ZKConfig;
package io.izenecloud.metaq;
public class Consumer {
private static Consumer metaqConsumer = null;
public static synchronized Consumer getInstance()
throws MetaClientException {
if (null == metaqConsumer) {
metaqConsumer = new Consumer();
}
return metaqConsumer;
}
private final Map<String, MessageConsumer> consumer;
public Consumer() {
consumer = new HashMap<String, MessageConsumer>();
}
public void subscribe(String collection, MessageListener listener)
throws MetaClientException { | final String urls = Configuration.getInstance().getMetaqZookeeper( |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/precompute/Mapper.java | // Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Matrix readMatrix(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return MatrixWritable.readMatrix(in);
// }
//
// Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Vector readVector(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return VectorWritable.readVector(in);
// }
| import static io.izenecloud.HDFSHelper.readMatrix;
import static io.izenecloud.HDFSHelper.readVector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.math.Matrix;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector; | package io.izenecloud.larser.offline.precompute;
public class Mapper extends
org.apache.hadoop.mapreduce.Mapper<Long, AdFeature, Long, Result> {
private Vector beta = null;
private Matrix A = null;
private Vector advec = null;
private List<Float> AStable = null;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
String offlineModel = conf.get("com.b5m.laser.offline.model");
Path offlinePath = new Path(offlineModel);
FileSystem fs = offlinePath.getFileSystem(conf); | // Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Matrix readMatrix(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return MatrixWritable.readMatrix(in);
// }
//
// Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Vector readVector(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return VectorWritable.readVector(in);
// }
// Path: src/main/java/io/izenecloud/larser/offline/precompute/Mapper.java
import static io.izenecloud.HDFSHelper.readMatrix;
import static io.izenecloud.HDFSHelper.readVector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.math.Matrix;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector;
package io.izenecloud.larser.offline.precompute;
public class Mapper extends
org.apache.hadoop.mapreduce.Mapper<Long, AdFeature, Long, Result> {
private Vector beta = null;
private Matrix A = null;
private Vector advec = null;
private List<Float> AStable = null;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
String offlineModel = conf.get("com.b5m.laser.offline.model");
Path offlinePath = new Path(offlineModel);
FileSystem fs = offlinePath.getFileSystem(conf); | beta = readVector(new Path(offlinePath, "beta"), fs, conf); |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/precompute/Mapper.java | // Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Matrix readMatrix(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return MatrixWritable.readMatrix(in);
// }
//
// Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Vector readVector(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return VectorWritable.readVector(in);
// }
| import static io.izenecloud.HDFSHelper.readMatrix;
import static io.izenecloud.HDFSHelper.readVector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.math.Matrix;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector; | package io.izenecloud.larser.offline.precompute;
public class Mapper extends
org.apache.hadoop.mapreduce.Mapper<Long, AdFeature, Long, Result> {
private Vector beta = null;
private Matrix A = null;
private Vector advec = null;
private List<Float> AStable = null;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
String offlineModel = conf.get("com.b5m.laser.offline.model");
Path offlinePath = new Path(offlineModel);
FileSystem fs = offlinePath.getFileSystem(conf);
beta = readVector(new Path(offlinePath, "beta"), fs, conf); | // Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Matrix readMatrix(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return MatrixWritable.readMatrix(in);
// }
//
// Path: src/main/java/io/izenecloud/HDFSHelper.java
// public static Vector readVector(Path path, FileSystem fs, Configuration conf)
// throws IOException {
// FSDataInputStream in = fs.open(path);
// return VectorWritable.readVector(in);
// }
// Path: src/main/java/io/izenecloud/larser/offline/precompute/Mapper.java
import static io.izenecloud.HDFSHelper.readMatrix;
import static io.izenecloud.HDFSHelper.readVector;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.math.Matrix;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector;
package io.izenecloud.larser.offline.precompute;
public class Mapper extends
org.apache.hadoop.mapreduce.Mapper<Long, AdFeature, Long, Result> {
private Vector beta = null;
private Matrix A = null;
private Vector advec = null;
private List<Float> AStable = null;
protected void setup(Context context) throws IOException,
InterruptedException {
Configuration conf = context.getConfiguration();
String offlineModel = conf.get("com.b5m.laser.offline.model");
Path offlinePath = new Path(offlineModel);
FileSystem fs = offlinePath.getFileSystem(conf);
beta = readVector(new Path(offlinePath, "beta"), fs, conf); | A = readMatrix(new Path(offlinePath, "A"), fs, conf); |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/precompute/AdFeature.java | // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
| import io.izenecloud.msgpack.SparseVector;
import org.msgpack.annotation.Message; | package io.izenecloud.larser.offline.precompute;
@Message
class AdFeature {
public Long k; | // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
// Path: src/main/java/io/izenecloud/larser/offline/precompute/AdFeature.java
import io.izenecloud.msgpack.SparseVector;
import org.msgpack.annotation.Message;
package io.izenecloud.larser.offline.precompute;
@Message
class AdFeature {
public Long k; | public SparseVector v; |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/precompute/Compute.java | // Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
//
// private long goalsize(Configuration conf) {
// String urlList = conf.get("com.b5m.laser.msgpack.host");
// int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// String collection = conf.get("com.b5m.laser.collection");
// String method = conf.get("com.b5m.laser.msgpack.input.method");
// MsgpackClient client = new MsgpackClient(urlList, port, collection);
// try {
// Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// Long.class);
// client.close();
// return size;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// @Override
// public List<InputSplit> getSplits(JobContext context) throws IOException,
// InterruptedException {
// Configuration conf = context.getConfiguration();
// long goalSize = goalsize(conf);
// String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// int numNode = urlList.length;
// List<InputSplit> splits = new ArrayList<InputSplit>();
// long splitLength = (long) Math.ceil((double) goalSize / numNode);
//
// long bytesRemaining = goalSize;
// for (int i = 0; i < numNode; i++) {
// if (bytesRemaining > splitLength) {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// splitLength, null));
// } else {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// bytesRemaining, null));
// }
// bytesRemaining -= splitLength;
// }
// return splits;
// }
//
// @Override
// public RecordReader<Long, V> createRecordReader(InputSplit split,
// TaskAttemptContext context) throws IOException,
// InterruptedException {
// return new MsgpackRecordReader<V>();
// }
//
// }
//
// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
| import io.izenecloud.msgpack.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job; | package io.izenecloud.larser.offline.precompute;
public class Compute {
public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
conf.set("com.b5m.laser.offline.model", model.toString());
Job job = Job.getInstance(conf);
job.setJarByClass(Compute.class);
job.setJobName("per compute stable part from offline model for each user"); | // Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
//
// private long goalsize(Configuration conf) {
// String urlList = conf.get("com.b5m.laser.msgpack.host");
// int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// String collection = conf.get("com.b5m.laser.collection");
// String method = conf.get("com.b5m.laser.msgpack.input.method");
// MsgpackClient client = new MsgpackClient(urlList, port, collection);
// try {
// Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// Long.class);
// client.close();
// return size;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// @Override
// public List<InputSplit> getSplits(JobContext context) throws IOException,
// InterruptedException {
// Configuration conf = context.getConfiguration();
// long goalSize = goalsize(conf);
// String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// int numNode = urlList.length;
// List<InputSplit> splits = new ArrayList<InputSplit>();
// long splitLength = (long) Math.ceil((double) goalSize / numNode);
//
// long bytesRemaining = goalSize;
// for (int i = 0; i < numNode; i++) {
// if (bytesRemaining > splitLength) {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// splitLength, null));
// } else {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// bytesRemaining, null));
// }
// bytesRemaining -= splitLength;
// }
// return splits;
// }
//
// @Override
// public RecordReader<Long, V> createRecordReader(InputSplit split,
// TaskAttemptContext context) throws IOException,
// InterruptedException {
// return new MsgpackRecordReader<V>();
// }
//
// }
//
// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
// Path: src/main/java/io/izenecloud/larser/offline/precompute/Compute.java
import io.izenecloud.msgpack.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
package io.izenecloud.larser.offline.precompute;
public class Compute {
public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
conf.set("com.b5m.laser.offline.model", model.toString());
Job job = Job.getInstance(conf);
job.setJarByClass(Compute.class);
job.setJobName("per compute stable part from offline model for each user"); | job.setInputFormatClass(MsgpackInputFormat.class); |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/precompute/Compute.java | // Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
//
// private long goalsize(Configuration conf) {
// String urlList = conf.get("com.b5m.laser.msgpack.host");
// int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// String collection = conf.get("com.b5m.laser.collection");
// String method = conf.get("com.b5m.laser.msgpack.input.method");
// MsgpackClient client = new MsgpackClient(urlList, port, collection);
// try {
// Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// Long.class);
// client.close();
// return size;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// @Override
// public List<InputSplit> getSplits(JobContext context) throws IOException,
// InterruptedException {
// Configuration conf = context.getConfiguration();
// long goalSize = goalsize(conf);
// String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// int numNode = urlList.length;
// List<InputSplit> splits = new ArrayList<InputSplit>();
// long splitLength = (long) Math.ceil((double) goalSize / numNode);
//
// long bytesRemaining = goalSize;
// for (int i = 0; i < numNode; i++) {
// if (bytesRemaining > splitLength) {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// splitLength, null));
// } else {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// bytesRemaining, null));
// }
// bytesRemaining -= splitLength;
// }
// return splits;
// }
//
// @Override
// public RecordReader<Long, V> createRecordReader(InputSplit split,
// TaskAttemptContext context) throws IOException,
// InterruptedException {
// return new MsgpackRecordReader<V>();
// }
//
// }
//
// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
| import io.izenecloud.msgpack.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job; | package io.izenecloud.larser.offline.precompute;
public class Compute {
public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
conf.set("com.b5m.laser.offline.model", model.toString());
Job job = Job.getInstance(conf);
job.setJarByClass(Compute.class);
job.setJobName("per compute stable part from offline model for each user");
job.setInputFormatClass(MsgpackInputFormat.class); | // Path: src/main/java/io/izenecloud/msgpack/MsgpackInputFormat.java
// public class MsgpackInputFormat<V> extends InputFormat<Long, V> {
//
// private long goalsize(Configuration conf) {
// String urlList = conf.get("com.b5m.laser.msgpack.host");
// int port = conf.getInt("com.b5m.laser.msgpack.port", 0);
// String collection = conf.get("com.b5m.laser.collection");
// String method = conf.get("com.b5m.laser.msgpack.input.method");
// MsgpackClient client = new MsgpackClient(urlList, port, collection);
// try {
// Long size = (Long) client.asyncRead(new Object[0], method + "|size",
// Long.class);
// client.close();
// return size;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// @Override
// public List<InputSplit> getSplits(JobContext context) throws IOException,
// InterruptedException {
// Configuration conf = context.getConfiguration();
// long goalSize = goalsize(conf);
// String[] urlList = conf.get("com.b5m.laser.msgpack.host").split(",");
// int numNode = urlList.length;
// List<InputSplit> splits = new ArrayList<InputSplit>();
// long splitLength = (long) Math.ceil((double) goalSize / numNode);
//
// long bytesRemaining = goalSize;
// for (int i = 0; i < numNode; i++) {
// if (bytesRemaining > splitLength) {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// splitLength, null));
// } else {
// splits.add(new FileSplit(new Path(urlList[i]), i * splitLength,
// bytesRemaining, null));
// }
// bytesRemaining -= splitLength;
// }
// return splits;
// }
//
// @Override
// public RecordReader<Long, V> createRecordReader(InputSplit split,
// TaskAttemptContext context) throws IOException,
// InterruptedException {
// return new MsgpackRecordReader<V>();
// }
//
// }
//
// Path: src/main/java/io/izenecloud/msgpack/MsgpackOutputFormat.java
// public class MsgpackOutputFormat<K, V> extends OutputFormat<K, V> {
//
// @Override
// public void checkOutputSpecs(JobContext context) throws IOException,
// InterruptedException {
// }
//
// @Override
// public OutputCommitter getOutputCommitter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new OutputCommitter() {
// public void abortTask(TaskAttemptContext taskContext) {
// }
//
// public void cleanupJob(JobContext jobContext) {
// }
//
// public void commitTask(TaskAttemptContext taskContext) {
// }
//
// public boolean needsTaskCommit(TaskAttemptContext taskContext) {
// return false;
// }
//
// public void setupJob(JobContext jobContext) {
// }
//
// public void setupTask(TaskAttemptContext taskContext) {
// }
//
//
// public boolean isRecoverySupported() {
// return true;
// }
//
//
// public void recoverTask(TaskAttemptContext taskContext)
// throws IOException {
// // Nothing to do for recovering the task.
// }
// };
// }
//
// @Override
// public RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
// throws IOException, InterruptedException {
// return new MsgpackRecordWriter<K, V>(context);
// }
//
// }
// Path: src/main/java/io/izenecloud/larser/offline/precompute/Compute.java
import io.izenecloud.msgpack.MsgpackInputFormat;
import io.izenecloud.msgpack.MsgpackOutputFormat;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.Job;
package io.izenecloud.larser.offline.precompute;
public class Compute {
public static int run(Path model, Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
conf.set("com.b5m.laser.msgpack.input.method", "ad_feature");
conf.set("com.b5m.laser.msgpack.output.method", "precompute_ad_offline_model");
conf.set("com.b5m.laser.offline.model", model.toString());
Job job = Job.getInstance(conf);
job.setJarByClass(Compute.class);
job.setJobName("per compute stable part from offline model for each user");
job.setInputFormatClass(MsgpackInputFormat.class); | job.setOutputFormatClass(MsgpackOutputFormat.class); |
izenecloud/laser | src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainerArguments.java | // Path: src/main/java/io/izenecloud/args4j/URIOptionHandler.java
// public class URIOptionHandler extends OneArgumentOptionHandler<URI> {
//
// public URIOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super URI> setter) {
// super(parser, option, setter);
// }
//
// @Override
// protected URI parse(String argument) throws NumberFormatException, CmdLineException {
// return URI.create(argument);
// }
// }
| import io.izenecloud.args4j.URIOptionHandler;
import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.BooleanOptionHandler;
import org.kohsuke.args4j.spi.FloatOptionHandler;
import org.kohsuke.args4j.spi.IntOptionHandler;
import org.kohsuke.args4j.spi.StringOptionHandler; | package io.izenecloud.larser.online;
public class LaserOnlineModelTrainerArguments {
public static final Set<String> VALID_ARGUMENTS = new HashSet<String>(
Arrays.asList("-outputPath", "-signalPath",
"-regularizationFactor", "-addIntercept"));
| // Path: src/main/java/io/izenecloud/args4j/URIOptionHandler.java
// public class URIOptionHandler extends OneArgumentOptionHandler<URI> {
//
// public URIOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super URI> setter) {
// super(parser, option, setter);
// }
//
// @Override
// protected URI parse(String argument) throws NumberFormatException, CmdLineException {
// return URI.create(argument);
// }
// }
// Path: src/main/java/io/izenecloud/larser/online/LaserOnlineModelTrainerArguments.java
import io.izenecloud.args4j.URIOptionHandler;
import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.BooleanOptionHandler;
import org.kohsuke.args4j.spi.FloatOptionHandler;
import org.kohsuke.args4j.spi.IntOptionHandler;
import org.kohsuke.args4j.spi.StringOptionHandler;
package io.izenecloud.larser.online;
public class LaserOnlineModelTrainerArguments {
public static final Set<String> VALID_ARGUMENTS = new HashSet<String>(
Arrays.asList("-outputPath", "-signalPath",
"-regularizationFactor", "-addIntercept"));
| @Option(name = "-outputPath", required = true, handler = URIOptionHandler.class) |
izenecloud/laser | src/main/java/io/izenecloud/couchbase/CouchbaseRecordReader.java | // Path: src/main/java/io/izenecloud/couchbase/CouchbaseInputFormat.java
// static class CouchbaseSplit extends InputSplit implements Writable {
// final List<Integer> vbuckets;
//
// CouchbaseSplit() {
// vbuckets = new ArrayList<Integer>();
// }
//
// CouchbaseSplit(List<Integer> vblist) {
// vbuckets = vblist;
// }
//
// public void readFields(DataInput in) throws IOException {
// short numvbuckets = in.readShort();
// for (int i = 0; i < numvbuckets; i++) {
// vbuckets.add(new Integer(in.readShort()));
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeShort(vbuckets.size());
// for (Integer v : vbuckets) {
// out.writeShort(v.shortValue());
// }
// }
//
// public long getLength() throws IOException {
// return vbuckets.size();
// }
//
// public String[] getLocations() {
// return new String[0];
// }
// }
| import io.izenecloud.couchbase.CouchbaseInputFormat.CouchbaseSplit;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.naming.ConfigurationException;
import net.spy.memcached.tapmessage.RequestMessage;
import net.spy.memcached.tapmessage.ResponseMessage;
import net.spy.memcached.tapmessage.TapMagic;
import net.spy.memcached.tapmessage.TapOpcode;
import net.spy.memcached.tapmessage.TapRequestFlag;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import com.couchbase.client.TapClient; | k.set(getCurrentKey());
v.set(getCurrentValue());
return true;
}
return false;
}
@Override
public void initialize(InputSplit split, TaskAttemptContext context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
final URI ClusterURI;
try {
ClusterURI = new URI(conf.get(CouchbaseConfig.CB_INPUT_CLUSTER));
} catch (URISyntaxException e) {
throw new IOException(e);
}
final List<URI> ClientURIList = new ArrayList<URI>();
ClientURIList.add(ClusterURI.resolve("/pools"));
final String bucket = conf.get(CouchbaseConfig.CB_INPUT_BUCKET,
"");
final String password = conf.get(CouchbaseConfig.CB_INPUT_PASSWORD, "");
RequestMessage tapReq = new RequestMessage();
tapReq.setMagic(TapMagic.PROTOCOL_BINARY_REQ);
tapReq.setOpcode(TapOpcode.REQUEST);
tapReq.setFlags(TapRequestFlag.DUMP);
tapReq.setFlags(TapRequestFlag.SUPPORT_ACK);
tapReq.setFlags(TapRequestFlag.FIX_BYTEORDER);
tapReq.setFlags(TapRequestFlag.LIST_VBUCKETS); | // Path: src/main/java/io/izenecloud/couchbase/CouchbaseInputFormat.java
// static class CouchbaseSplit extends InputSplit implements Writable {
// final List<Integer> vbuckets;
//
// CouchbaseSplit() {
// vbuckets = new ArrayList<Integer>();
// }
//
// CouchbaseSplit(List<Integer> vblist) {
// vbuckets = vblist;
// }
//
// public void readFields(DataInput in) throws IOException {
// short numvbuckets = in.readShort();
// for (int i = 0; i < numvbuckets; i++) {
// vbuckets.add(new Integer(in.readShort()));
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeShort(vbuckets.size());
// for (Integer v : vbuckets) {
// out.writeShort(v.shortValue());
// }
// }
//
// public long getLength() throws IOException {
// return vbuckets.size();
// }
//
// public String[] getLocations() {
// return new String[0];
// }
// }
// Path: src/main/java/io/izenecloud/couchbase/CouchbaseRecordReader.java
import io.izenecloud.couchbase.CouchbaseInputFormat.CouchbaseSplit;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.naming.ConfigurationException;
import net.spy.memcached.tapmessage.RequestMessage;
import net.spy.memcached.tapmessage.ResponseMessage;
import net.spy.memcached.tapmessage.TapMagic;
import net.spy.memcached.tapmessage.TapOpcode;
import net.spy.memcached.tapmessage.TapRequestFlag;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import com.couchbase.client.TapClient;
k.set(getCurrentKey());
v.set(getCurrentValue());
return true;
}
return false;
}
@Override
public void initialize(InputSplit split, TaskAttemptContext context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
final URI ClusterURI;
try {
ClusterURI = new URI(conf.get(CouchbaseConfig.CB_INPUT_CLUSTER));
} catch (URISyntaxException e) {
throw new IOException(e);
}
final List<URI> ClientURIList = new ArrayList<URI>();
ClientURIList.add(ClusterURI.resolve("/pools"));
final String bucket = conf.get(CouchbaseConfig.CB_INPUT_BUCKET,
"");
final String password = conf.get(CouchbaseConfig.CB_INPUT_PASSWORD, "");
RequestMessage tapReq = new RequestMessage();
tapReq.setMagic(TapMagic.PROTOCOL_BINARY_REQ);
tapReq.setOpcode(TapOpcode.REQUEST);
tapReq.setFlags(TapRequestFlag.DUMP);
tapReq.setFlags(TapRequestFlag.SUPPORT_ACK);
tapReq.setFlags(TapRequestFlag.FIX_BYTEORDER);
tapReq.setFlags(TapRequestFlag.LIST_VBUCKETS); | final CouchbaseSplit couchSplit = (CouchbaseSplit) split; |
izenecloud/laser | src/main/java/io/izenecloud/larser/offline/topn/AdClusteringInfo.java | // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
| import io.izenecloud.msgpack.SparseVector;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector; | package io.izenecloud.larser.offline.topn;
class AdClusteringInfo {
private Integer clusteringId;
private Vector info;
| // Path: src/main/java/io/izenecloud/msgpack/SparseVector.java
// @Message
// public class SparseVector {
// public List<Integer> index;
// public List<Float> value;
//
// @Ignore
// private Iterator<Integer> iit = null;
// @Ignore
// private Iterator<Float> vit = null;
//
// public SparseVector() {
//
// }
//
// public SparseVector(List<Integer> index, List<Float> value) {
// this.index = index;
// this.value = value;
// }
//
// public boolean hasNext() {
// if (null == iit || null == vit) {
// iit = index.iterator();
// vit = value.iterator();
// }
// return iit.hasNext() && vit.hasNext();
// }
//
// public Integer getIndex() {
// return iit.next();
// }
//
// public Float get() {
// return vit.next();
// }
// }
// Path: src/main/java/io/izenecloud/larser/offline/topn/AdClusteringInfo.java
import io.izenecloud.msgpack.SparseVector;
import org.apache.mahout.math.SequentialAccessSparseVector;
import org.apache.mahout.math.Vector;
package io.izenecloud.larser.offline.topn;
class AdClusteringInfo {
private Integer clusteringId;
private Vector info;
| public AdClusteringInfo(Integer id, SparseVector sv, int dimension) { |
izenecloud/laser | src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
//
// Path: src/main/java/io/izenecloud/lr/ListWritable.java
// public class ListWritable implements Writable {
// private Class<? extends Writable> valueClass;
// private Class<? extends List> listClass;
// private List<Writable> values;
//
// public ListWritable() {
// }
//
// public ListWritable(List<Writable> values) {
// listClass = values.getClass();
// valueClass = values.get(0).getClass();
// this.values = values;
// }
//
// public Class<? extends Writable> getValueClass() {
// return valueClass;
// }
//
// @SuppressWarnings("rawtypes")
// public Class<? extends List> getListClass() {
// return listClass;
// }
//
// public void set(List<Writable> values) {
// this.values = values;
// }
//
// public List<Writable> get() {
// return values;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public void readFields(DataInput in) throws IOException {
// String listClass = in.readUTF();
// try {
// this.listClass = (Class<? extends List>) Class.forName(listClass);
// String valueClass = in.readUTF();
// this.valueClass = (Class<? extends Writable>) Class
// .forName(valueClass);
// } catch (ClassNotFoundException e1) {
// e1.printStackTrace();
// }
//
// int size = in.readInt(); // construct values
// try {
// values = this.listClass.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// for (int i = 0; i < size; i++) {
// Writable value = WritableFactories.newInstance(this.valueClass);
// value.readFields(in); // read a value
// values.add(value); // store it in values
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeUTF(listClass.getName());
// out.writeUTF(valueClass.getName());
// out.writeInt(values.size()); // write values
// Iterator<Writable> iterator = values.iterator();
// while (iterator.hasNext()) {
// iterator.next().write(out);
// }
// }
//
// }
| import io.izenecloud.larser.feature.OnlineVectorWritable;
import io.izenecloud.lr.ListWritable;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package io.izenecloud.larser.feature.online;
public class OnlineFeatureDriver {
private static final Logger LOG = LoggerFactory
.getLogger(OnlineFeatureDriver.class);
public static long run(String collection, Path input, Path output,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
Job job = Job.getInstance(conf);
job.setJarByClass(OnlineFeatureDriver.class);
job.setJobName("GROUP each record's feature BY identifier");
FileInputFormat.setInputPaths(job, input);
FileOutputFormat.setOutputPath(job, output);
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setMapOutputKeyClass(Text.class); | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
//
// Path: src/main/java/io/izenecloud/lr/ListWritable.java
// public class ListWritable implements Writable {
// private Class<? extends Writable> valueClass;
// private Class<? extends List> listClass;
// private List<Writable> values;
//
// public ListWritable() {
// }
//
// public ListWritable(List<Writable> values) {
// listClass = values.getClass();
// valueClass = values.get(0).getClass();
// this.values = values;
// }
//
// public Class<? extends Writable> getValueClass() {
// return valueClass;
// }
//
// @SuppressWarnings("rawtypes")
// public Class<? extends List> getListClass() {
// return listClass;
// }
//
// public void set(List<Writable> values) {
// this.values = values;
// }
//
// public List<Writable> get() {
// return values;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public void readFields(DataInput in) throws IOException {
// String listClass = in.readUTF();
// try {
// this.listClass = (Class<? extends List>) Class.forName(listClass);
// String valueClass = in.readUTF();
// this.valueClass = (Class<? extends Writable>) Class
// .forName(valueClass);
// } catch (ClassNotFoundException e1) {
// e1.printStackTrace();
// }
//
// int size = in.readInt(); // construct values
// try {
// values = this.listClass.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// for (int i = 0; i < size; i++) {
// Writable value = WritableFactories.newInstance(this.valueClass);
// value.readFields(in); // read a value
// values.add(value); // store it in values
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeUTF(listClass.getName());
// out.writeUTF(valueClass.getName());
// out.writeInt(values.size()); // write values
// Iterator<Writable> iterator = values.iterator();
// while (iterator.hasNext()) {
// iterator.next().write(out);
// }
// }
//
// }
// Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
import io.izenecloud.larser.feature.OnlineVectorWritable;
import io.izenecloud.lr.ListWritable;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package io.izenecloud.larser.feature.online;
public class OnlineFeatureDriver {
private static final Logger LOG = LoggerFactory
.getLogger(OnlineFeatureDriver.class);
public static long run(String collection, Path input, Path output,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
Job job = Job.getInstance(conf);
job.setJarByClass(OnlineFeatureDriver.class);
job.setJobName("GROUP each record's feature BY identifier");
FileInputFormat.setInputPaths(job, input);
FileOutputFormat.setOutputPath(job, output);
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setMapOutputKeyClass(Text.class); | job.setMapOutputValueClass(OnlineVectorWritable.class); |
izenecloud/laser | src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
//
// Path: src/main/java/io/izenecloud/lr/ListWritable.java
// public class ListWritable implements Writable {
// private Class<? extends Writable> valueClass;
// private Class<? extends List> listClass;
// private List<Writable> values;
//
// public ListWritable() {
// }
//
// public ListWritable(List<Writable> values) {
// listClass = values.getClass();
// valueClass = values.get(0).getClass();
// this.values = values;
// }
//
// public Class<? extends Writable> getValueClass() {
// return valueClass;
// }
//
// @SuppressWarnings("rawtypes")
// public Class<? extends List> getListClass() {
// return listClass;
// }
//
// public void set(List<Writable> values) {
// this.values = values;
// }
//
// public List<Writable> get() {
// return values;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public void readFields(DataInput in) throws IOException {
// String listClass = in.readUTF();
// try {
// this.listClass = (Class<? extends List>) Class.forName(listClass);
// String valueClass = in.readUTF();
// this.valueClass = (Class<? extends Writable>) Class
// .forName(valueClass);
// } catch (ClassNotFoundException e1) {
// e1.printStackTrace();
// }
//
// int size = in.readInt(); // construct values
// try {
// values = this.listClass.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// for (int i = 0; i < size; i++) {
// Writable value = WritableFactories.newInstance(this.valueClass);
// value.readFields(in); // read a value
// values.add(value); // store it in values
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeUTF(listClass.getName());
// out.writeUTF(valueClass.getName());
// out.writeInt(values.size()); // write values
// Iterator<Writable> iterator = values.iterator();
// while (iterator.hasNext()) {
// iterator.next().write(out);
// }
// }
//
// }
| import io.izenecloud.larser.feature.OnlineVectorWritable;
import io.izenecloud.lr.ListWritable;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package io.izenecloud.larser.feature.online;
public class OnlineFeatureDriver {
private static final Logger LOG = LoggerFactory
.getLogger(OnlineFeatureDriver.class);
public static long run(String collection, Path input, Path output,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
Job job = Job.getInstance(conf);
job.setJarByClass(OnlineFeatureDriver.class);
job.setJobName("GROUP each record's feature BY identifier");
FileInputFormat.setInputPaths(job, input);
FileOutputFormat.setOutputPath(job, output);
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(OnlineVectorWritable.class);
job.setOutputKeyClass(Text.class); | // Path: src/main/java/io/izenecloud/larser/feature/OnlineVectorWritable.java
// public class OnlineVectorWritable implements Writable {
// private Double offset;
// private Integer action;
// private Vector sample;
//
// public OnlineVectorWritable() {
//
// }
//
// public OnlineVectorWritable(Double offset, Integer action, Vector sample) {
// this.offset = offset;
// this.action = action;
// this.sample = sample;
// }
//
// public Double getOffset() {
// return offset;
// }
//
// public Integer getOction() {
// return action;
// }
//
// public Vector getSample() {
// return sample;
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeDouble(offset);
// out.writeInt(action);
// VectorWritable.writeVector(out, sample);
// }
//
// public void readFields(DataInput in) throws IOException {
// offset = in.readDouble();
// action = in.readInt();
// sample = VectorWritable.readVector(in);
// }
//
// }
//
// Path: src/main/java/io/izenecloud/lr/ListWritable.java
// public class ListWritable implements Writable {
// private Class<? extends Writable> valueClass;
// private Class<? extends List> listClass;
// private List<Writable> values;
//
// public ListWritable() {
// }
//
// public ListWritable(List<Writable> values) {
// listClass = values.getClass();
// valueClass = values.get(0).getClass();
// this.values = values;
// }
//
// public Class<? extends Writable> getValueClass() {
// return valueClass;
// }
//
// @SuppressWarnings("rawtypes")
// public Class<? extends List> getListClass() {
// return listClass;
// }
//
// public void set(List<Writable> values) {
// this.values = values;
// }
//
// public List<Writable> get() {
// return values;
// }
//
// @SuppressWarnings({ "unchecked", "rawtypes" })
// public void readFields(DataInput in) throws IOException {
// String listClass = in.readUTF();
// try {
// this.listClass = (Class<? extends List>) Class.forName(listClass);
// String valueClass = in.readUTF();
// this.valueClass = (Class<? extends Writable>) Class
// .forName(valueClass);
// } catch (ClassNotFoundException e1) {
// e1.printStackTrace();
// }
//
// int size = in.readInt(); // construct values
// try {
// values = this.listClass.newInstance();
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// for (int i = 0; i < size; i++) {
// Writable value = WritableFactories.newInstance(this.valueClass);
// value.readFields(in); // read a value
// values.add(value); // store it in values
// }
// }
//
// public void write(DataOutput out) throws IOException {
// out.writeUTF(listClass.getName());
// out.writeUTF(valueClass.getName());
// out.writeInt(values.size()); // write values
// Iterator<Writable> iterator = values.iterator();
// while (iterator.hasNext()) {
// iterator.next().write(out);
// }
// }
//
// }
// Path: src/main/java/io/izenecloud/larser/feature/online/OnlineFeatureDriver.java
import io.izenecloud.larser.feature.OnlineVectorWritable;
import io.izenecloud.lr.ListWritable;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.mahout.common.HadoopUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package io.izenecloud.larser.feature.online;
public class OnlineFeatureDriver {
private static final Logger LOG = LoggerFactory
.getLogger(OnlineFeatureDriver.class);
public static long run(String collection, Path input, Path output,
Configuration baseConf) throws IOException, ClassNotFoundException,
InterruptedException {
Configuration conf = new Configuration(baseConf);
Job job = Job.getInstance(conf);
job.setJarByClass(OnlineFeatureDriver.class);
job.setJobName("GROUP each record's feature BY identifier");
FileInputFormat.setInputPaths(job, input);
FileOutputFormat.setOutputPath(job, output);
job.setInputFormatClass(SequenceFileInputFormat.class);
job.setOutputFormatClass(SequenceFileOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(OnlineVectorWritable.class);
job.setOutputKeyClass(Text.class); | job.setOutputValueClass(ListWritable.class); |
izenecloud/laser | src/main/java/io/izenecloud/admm/AdmmOptimizerDriverArguments.java | // Path: src/main/java/io/izenecloud/args4j/URIOptionHandler.java
// public class URIOptionHandler extends OneArgumentOptionHandler<URI> {
//
// public URIOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super URI> setter) {
// super(parser, option, setter);
// }
//
// @Override
// protected URI parse(String argument) throws NumberFormatException, CmdLineException {
// return URI.create(argument);
// }
// }
| import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.BooleanOptionHandler;
import org.kohsuke.args4j.spi.FloatOptionHandler;
import org.kohsuke.args4j.spi.IntOptionHandler;
import org.kohsuke.args4j.spi.StringOptionHandler;
import io.izenecloud.args4j.URIOptionHandler;
import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set; | package io.izenecloud.admm;
public class AdmmOptimizerDriverArguments {
public static final Set<String> VALID_ARGUMENTS = new HashSet<String>(
Arrays.asList("-outputPath", "-signalPath", "-iterationsMaximum",
"-regularizationFactor", "-addIntercept",
"-regularizeIntercept"));
| // Path: src/main/java/io/izenecloud/args4j/URIOptionHandler.java
// public class URIOptionHandler extends OneArgumentOptionHandler<URI> {
//
// public URIOptionHandler(CmdLineParser parser, OptionDef option, Setter<? super URI> setter) {
// super(parser, option, setter);
// }
//
// @Override
// protected URI parse(String argument) throws NumberFormatException, CmdLineException {
// return URI.create(argument);
// }
// }
// Path: src/main/java/io/izenecloud/admm/AdmmOptimizerDriverArguments.java
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.BooleanOptionHandler;
import org.kohsuke.args4j.spi.FloatOptionHandler;
import org.kohsuke.args4j.spi.IntOptionHandler;
import org.kohsuke.args4j.spi.StringOptionHandler;
import io.izenecloud.args4j.URIOptionHandler;
import java.net.URI;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
package io.izenecloud.admm;
public class AdmmOptimizerDriverArguments {
public static final Set<String> VALID_ARGUMENTS = new HashSet<String>(
Arrays.asList("-outputPath", "-signalPath", "-iterationsMaximum",
"-regularizationFactor", "-addIntercept",
"-regularizeIntercept"));
| @Option(name = "-outputPath", required = true, handler = URIOptionHandler.class) |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map; | /**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out; | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map;
/**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out; | private RecordFormat format; |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map; | /**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map;
/**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
| public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){ |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map; | /**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map;
/**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
| public HdfsBolt withSyncPolicy(SyncPolicy syncPolicy){ |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map; | /**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
public HdfsBolt withSyncPolicy(SyncPolicy syncPolicy){
this.syncPolicy = syncPolicy;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map;
/**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
public HdfsBolt withSyncPolicy(SyncPolicy syncPolicy){
this.syncPolicy = syncPolicy;
return this;
}
| public HdfsBolt withRotationPolicy(FileRotationPolicy rotationPolicy){ |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map; | /**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
public HdfsBolt withSyncPolicy(SyncPolicy syncPolicy){
this.syncPolicy = syncPolicy;
return this;
}
public HdfsBolt withRotationPolicy(FileRotationPolicy rotationPolicy){
this.rotationPolicy = rotationPolicy;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/RecordFormat.java
// public interface RecordFormat extends Serializable {
// byte[] format(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/HdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.RecordFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.EnumSet;
import java.util.Map;
/**
* 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.storm.hdfs.bolt;
public class HdfsBolt extends AbstractHdfsBolt{
private static final Logger LOG = LoggerFactory.getLogger(HdfsBolt.class);
private transient FSDataOutputStream out;
private RecordFormat format;
private long offset = 0;
public HdfsBolt withFsUrl(String fsUrl){
this.fsUrl = fsUrl;
return this;
}
public HdfsBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public HdfsBolt withFileNameFormat(FileNameFormat fileNameFormat){
this.fileNameFormat = fileNameFormat;
return this;
}
public HdfsBolt withRecordFormat(RecordFormat format){
this.format = format;
return this;
}
public HdfsBolt withSyncPolicy(SyncPolicy syncPolicy){
this.syncPolicy = syncPolicy;
return this;
}
public HdfsBolt withRotationPolicy(FileRotationPolicy rotationPolicy){
this.rotationPolicy = rotationPolicy;
return this;
}
| public HdfsBolt addRotationAction(RotationAction action){ |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger; | /**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
/**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
| private SequenceFormat format; |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger; | /**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
private SequenceFormat format;
private SequenceFile.CompressionType compressionType = SequenceFile.CompressionType.RECORD;
private transient SequenceFile.Writer writer;
private String compressionCodec = "default";
private transient CompressionCodecFactory codecFactory;
public SequenceFileBolt() {
}
public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
/**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
private SequenceFormat format;
private SequenceFile.CompressionType compressionType = SequenceFile.CompressionType.RECORD;
private transient SequenceFile.Writer writer;
private String compressionCodec = "default";
private transient CompressionCodecFactory codecFactory;
public SequenceFileBolt() {
}
public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
| public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) { |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger; | /**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
private SequenceFormat format;
private SequenceFile.CompressionType compressionType = SequenceFile.CompressionType.RECORD;
private transient SequenceFile.Writer writer;
private String compressionCodec = "default";
private transient CompressionCodecFactory codecFactory;
public SequenceFileBolt() {
}
public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
/**
* 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.storm.hdfs.bolt;
public class SequenceFileBolt extends AbstractHdfsBolt {
private static final Logger LOG = LoggerFactory.getLogger(SequenceFileBolt.class);
private SequenceFormat format;
private SequenceFile.CompressionType compressionType = SequenceFile.CompressionType.RECORD;
private transient SequenceFile.Writer writer;
private String compressionCodec = "default";
private transient CompressionCodecFactory codecFactory;
public SequenceFileBolt() {
}
public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
| public SequenceFileBolt withSyncPolicy(SyncPolicy syncPolicy) { |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger; | public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
public SequenceFileBolt withSyncPolicy(SyncPolicy syncPolicy) {
this.syncPolicy = syncPolicy;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
public SequenceFileBolt withCompressionCodec(String codec){
this.compressionCodec = codec;
return this;
}
public SequenceFileBolt withFsUrl(String fsUrl) {
this.fsUrl = fsUrl;
return this;
}
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
public SequenceFileBolt withSyncPolicy(SyncPolicy syncPolicy) {
this.syncPolicy = syncPolicy;
return this;
}
| public SequenceFileBolt withRotationPolicy(FileRotationPolicy rotationPolicy) { |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
| import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger; | public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
public SequenceFileBolt withSyncPolicy(SyncPolicy syncPolicy) {
this.syncPolicy = syncPolicy;
return this;
}
public SequenceFileBolt withRotationPolicy(FileRotationPolicy rotationPolicy) {
this.rotationPolicy = rotationPolicy;
return this;
}
public SequenceFileBolt withCompressionType(SequenceFile.CompressionType compressionType){
this.compressionType = compressionType;
return this;
}
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/format/SequenceFormat.java
// public interface SequenceFormat extends Serializable {
// /**
// * Key class used by implementation (e.g. IntWritable.class, etc.)
// *
// * @return
// */
// Class keyClass();
//
// /**
// * Value class used by implementation (e.g. Text.class, etc.)
// * @return
// */
// Class valueClass();
//
// /**
// * Given a tuple, return the key that should be written to the sequence file.
// *
// * @param tuple
// * @return
// */
// Writable key(Tuple tuple);
//
// /**
// * Given a tuple, return the value that should be written to the sequence file.
// * @param tuple
// * @return
// */
// Writable value(Tuple tuple);
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/SequenceFileBolt.java
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.tuple.Tuple;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.CompressionCodecFactory;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.format.SequenceFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.slf4j.Logger;
public SequenceFileBolt withConfigKey(String configKey){
this.configKey = configKey;
return this;
}
public SequenceFileBolt withFileNameFormat(FileNameFormat fileNameFormat) {
this.fileNameFormat = fileNameFormat;
return this;
}
public SequenceFileBolt withSequenceFormat(SequenceFormat format) {
this.format = format;
return this;
}
public SequenceFileBolt withSyncPolicy(SyncPolicy syncPolicy) {
this.syncPolicy = syncPolicy;
return this;
}
public SequenceFileBolt withRotationPolicy(FileRotationPolicy rotationPolicy) {
this.rotationPolicy = rotationPolicy;
return this;
}
public SequenceFileBolt withCompressionType(SequenceFile.CompressionType compressionType){
this.compressionType = compressionType;
return this;
}
| public SequenceFileBolt addRotationAction(RotationAction action){ |
ptgoetz/storm-hdfs | src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
| import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple; | package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
| // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
// Path: src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple;
package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
| FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); |
ptgoetz/storm-hdfs | src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
| import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple; | package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
| // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
// Path: src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple;
package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
| FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); |
ptgoetz/storm-hdfs | src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
| import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple; | package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB);
HdfsState.Options seqOpts = new HdfsState.SequenceFileOptions()
.withFileNameFormat(fileNameFormat)
.withSequenceFormat(new DefaultSequenceFormat("key", "sentence"))
.withRotationPolicy(rotationPolicy)
.withFsUrl(hdfsUrl) | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
// Path: src/test/java/org/apache/storm/hdfs/trident/TridentSequenceTopology.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple;
package org.apache.storm.hdfs.trident;
public class TridentSequenceTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".seq");
FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB);
HdfsState.Options seqOpts = new HdfsState.SequenceFileOptions()
.withFileNameFormat(fileNameFormat)
.withSequenceFormat(new DefaultSequenceFormat("key", "sentence"))
.withRotationPolicy(rotationPolicy)
.withFsUrl(hdfsUrl) | .addRotationAction(new MoveFileAction().toDestination("/dest2/")); |
ptgoetz/storm-hdfs | src/main/java/org/apache/storm/hdfs/bolt/AbstractHdfsBolt.java | // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/TimedRotationPolicy.java
// public class TimedRotationPolicy implements FileRotationPolicy {
//
// public static enum TimeUnit {
//
// SECONDS((long)1000),
// MINUTES((long)1000*60),
// HOURS((long)1000*60*60),
// DAYS((long)1000*60*60*24);
//
// private long milliSeconds;
//
// private TimeUnit(long milliSeconds){
// this.milliSeconds = milliSeconds;
// }
//
// public long getMilliSeconds(){
// return milliSeconds;
// }
// }
//
// private long interval;
//
// public TimedRotationPolicy(float count, TimeUnit units){
// this.interval = (long)(count * units.getMilliSeconds());
// }
//
//
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// @Override
// public boolean mark(Tuple tuple, long offset) {
// return false;
// }
//
// /**
// * Called after the HdfsBolt rotates a file.
// */
// @Override
// public void reset() {
//
// }
//
// public long getInterval(){
// return this.interval;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
// public class HdfsSecurityUtil {
// public static final String STORM_KEYTAB_FILE_KEY = "hdfs.keytab.file";
// public static final String STORM_USER_NAME_KEY = "hdfs.kerberos.principal";
//
// public static void login(Map conf, Configuration hdfsConfig) throws IOException {
// if (UserGroupInformation.isSecurityEnabled()) {
// String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
// if (keytab != null) {
// hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
// }
// String userName = (String) conf.get(STORM_USER_NAME_KEY);
// if (userName != null) {
// hdfsConfig.set(STORM_USER_NAME_KEY, userName);
// }
// SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
// }
// }
// }
| import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.rotation.TimedRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.apache.storm.hdfs.common.security.HdfsSecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask; | /**
* 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.storm.hdfs.bolt;
public abstract class AbstractHdfsBolt extends BaseRichBolt {
private static final Logger LOG = LoggerFactory.getLogger(AbstractHdfsBolt.class);
| // Path: src/main/java/org/apache/storm/hdfs/bolt/format/FileNameFormat.java
// public interface FileNameFormat extends Serializable {
//
// void prepare(Map conf, TopologyContext topologyContext);
//
// /**
// * Returns the filename the HdfsBolt will create.
// * @param rotation the current file rotation number (incremented on every rotation)
// * @param timeStamp current time in milliseconds when the rotation occurs
// * @return
// */
// String getName(long rotation, long timeStamp);
//
// String getPath();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/rotation/TimedRotationPolicy.java
// public class TimedRotationPolicy implements FileRotationPolicy {
//
// public static enum TimeUnit {
//
// SECONDS((long)1000),
// MINUTES((long)1000*60),
// HOURS((long)1000*60*60),
// DAYS((long)1000*60*60*24);
//
// private long milliSeconds;
//
// private TimeUnit(long milliSeconds){
// this.milliSeconds = milliSeconds;
// }
//
// public long getMilliSeconds(){
// return milliSeconds;
// }
// }
//
// private long interval;
//
// public TimedRotationPolicy(float count, TimeUnit units){
// this.interval = (long)(count * units.getMilliSeconds());
// }
//
//
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// @Override
// public boolean mark(Tuple tuple, long offset) {
// return false;
// }
//
// /**
// * Called after the HdfsBolt rotates a file.
// */
// @Override
// public void reset() {
//
// }
//
// public long getInterval(){
// return this.interval;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/bolt/sync/SyncPolicy.java
// public interface SyncPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset for the file being written
// * @return true if a sync should be performed
// */
// boolean mark(Tuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt performs a sync.
// *
// */
// void reset();
//
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/rotation/RotationAction.java
// public interface RotationAction extends Serializable {
// void execute(FileSystem fileSystem, Path filePath) throws IOException;
// }
//
// Path: src/main/java/org/apache/storm/hdfs/common/security/HdfsSecurityUtil.java
// public class HdfsSecurityUtil {
// public static final String STORM_KEYTAB_FILE_KEY = "hdfs.keytab.file";
// public static final String STORM_USER_NAME_KEY = "hdfs.kerberos.principal";
//
// public static void login(Map conf, Configuration hdfsConfig) throws IOException {
// if (UserGroupInformation.isSecurityEnabled()) {
// String keytab = (String) conf.get(STORM_KEYTAB_FILE_KEY);
// if (keytab != null) {
// hdfsConfig.set(STORM_KEYTAB_FILE_KEY, keytab);
// }
// String userName = (String) conf.get(STORM_USER_NAME_KEY);
// if (userName != null) {
// hdfsConfig.set(STORM_USER_NAME_KEY, userName);
// }
// SecurityUtil.login(hdfsConfig, STORM_KEYTAB_FILE_KEY, STORM_USER_NAME_KEY);
// }
// }
// }
// Path: src/main/java/org/apache/storm/hdfs/bolt/AbstractHdfsBolt.java
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.storm.hdfs.bolt.format.FileNameFormat;
import org.apache.storm.hdfs.bolt.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.bolt.rotation.TimedRotationPolicy;
import org.apache.storm.hdfs.bolt.sync.SyncPolicy;
import org.apache.storm.hdfs.common.rotation.RotationAction;
import org.apache.storm.hdfs.common.security.HdfsSecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
/**
* 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.storm.hdfs.bolt;
public abstract class AbstractHdfsBolt extends BaseRichBolt {
private static final Logger LOG = LoggerFactory.getLogger(AbstractHdfsBolt.class);
| protected ArrayList<RotationAction> rotationActions = new ArrayList<RotationAction>(); |
ptgoetz/storm-hdfs | src/test/java/org/apache/storm/hdfs/trident/TridentFileTopology.java | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
| import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple; | package org.apache.storm.hdfs.trident;
public class TridentFileTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".txt");
RecordFormat recordFormat = new DelimitedRecordFormat()
.withFields(hdfsFields);
| // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
// Path: src/test/java/org/apache/storm/hdfs/trident/TridentFileTopology.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple;
package org.apache.storm.hdfs.trident;
public class TridentFileTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".txt");
RecordFormat recordFormat = new DelimitedRecordFormat()
.withFields(hdfsFields);
| FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); |
ptgoetz/storm-hdfs | src/test/java/org/apache/storm/hdfs/trident/TridentFileTopology.java | // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
| import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple; | package org.apache.storm.hdfs.trident;
public class TridentFileTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".txt");
RecordFormat recordFormat = new DelimitedRecordFormat()
.withFields(hdfsFields);
| // Path: src/main/java/org/apache/storm/hdfs/common/rotation/MoveFileAction.java
// public class MoveFileAction implements RotationAction {
// private static final Logger LOG = LoggerFactory.getLogger(MoveFileAction.class);
//
// private String destination;
//
// public MoveFileAction toDestination(String destDir){
// destination = destDir;
// return this;
// }
//
// @Override
// public void execute(FileSystem fileSystem, Path filePath) throws IOException {
// Path destPath = new Path(destination, filePath.getName());
// LOG.info("Moving file {} to {}", filePath, destPath);
// boolean success = fileSystem.rename(filePath, destPath);
// return;
// }
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileRotationPolicy.java
// public interface FileRotationPolicy extends Serializable {
// /**
// * Called for every tuple the HdfsBolt executes.
// *
// * @param tuple The tuple executed.
// * @param offset current offset of file being written
// * @return true if a file rotation should be performed
// */
// boolean mark(TridentTuple tuple, long offset);
//
//
// /**
// * Called after the HdfsBolt rotates a file.
// *
// */
// void reset();
// }
//
// Path: src/main/java/org/apache/storm/hdfs/trident/rotation/FileSizeRotationPolicy.java
// public class FileSizeRotationPolicy implements FileRotationPolicy {
// private static final Logger LOG = LoggerFactory.getLogger(FileSizeRotationPolicy.class);
//
// public static enum Units {
//
// KB((long)Math.pow(2, 10)),
// MB((long)Math.pow(2, 20)),
// GB((long)Math.pow(2, 30)),
// TB((long)Math.pow(2, 40));
//
// private long byteCount;
//
// private Units(long byteCount){
// this.byteCount = byteCount;
// }
//
// public long getByteCount(){
// return byteCount;
// }
// }
//
// private long maxBytes;
//
// private long lastOffset = 0;
// private long currentBytesWritten = 0;
//
// public FileSizeRotationPolicy(float count, Units units){
// this.maxBytes = (long)(count * units.getByteCount());
// }
//
// @Override
// public boolean mark(TridentTuple tuple, long offset) {
// long diff = offset - this.lastOffset;
// this.currentBytesWritten += diff;
// this.lastOffset = offset;
// return this.currentBytesWritten >= this.maxBytes;
// }
//
// @Override
// public void reset() {
// this.currentBytesWritten = 0;
// this.lastOffset = 0;
// }
//
// }
// Path: src/test/java/org/apache/storm/hdfs/trident/TridentFileTopology.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.apache.storm.hdfs.common.rotation.MoveFileAction;
import org.apache.storm.hdfs.trident.format.*;
import org.apache.storm.hdfs.trident.rotation.FileRotationPolicy;
import org.apache.storm.hdfs.trident.rotation.FileSizeRotationPolicy;
import storm.trident.Stream;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.state.StateFactory;
import storm.trident.tuple.TridentTuple;
package org.apache.storm.hdfs.trident;
public class TridentFileTopology {
public static StormTopology buildTopology(String hdfsUrl){
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields hdfsFields = new Fields("sentence", "key");
FileNameFormat fileNameFormat = new DefaultFileNameFormat()
.withPath("/trident")
.withPrefix("trident")
.withExtension(".txt");
RecordFormat recordFormat = new DelimitedRecordFormat()
.withFields(hdfsFields);
| FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, FileSizeRotationPolicy.Units.MB); |
danfang/house-devs | android/app/src/main/java/hack/com/househunt/internal/Util.java | // Path: android/app/src/main/java/hack/com/househunt/api/HouseHuntRestClient.java
// public class HouseHuntRestClient {
//
// private static final String BASE_URL = "http://54.148.214.208:3000/api/";
//
// private static AsyncHttpClient client = new AsyncHttpClient();
//
// public static void get(String url, RequestParams params,
// AsyncHttpResponseHandler responseHandler) {
// client.get(getAbsoluteUrl(url), params, responseHandler);
// }
//
// public static void post(String url, StringEntity params,
// AsyncHttpResponseHandler responseHandler) {
// client.post(null, getAbsoluteUrl(url), params, "application/json", responseHandler);
// }
//
// private static String getAbsoluteUrl(String relativeUrl) {
// return BASE_URL + relativeUrl;
// }
//
// }
//
// Path: android/app/src/main/java/hack/com/househunt/fragments/RecommendFragment.java
// public class RecommendFragment extends Fragment {
//
// public static final String TAG = RecommendFragment.class.getSimpleName();
//
// @InjectView(R.id.card_stack) CardContainer mLiveableCards;
// private CardDataAdapter mAdapter;
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.recommend_frag, container, false);
// ButterKnife.inject(this, v);
// List<Liveable> liveables = UserSession.getInstance().getRecommendedLiveables();
// mAdapter = new CardDataAdapter(getActivity(), R.layout.liveable_card, liveables);
// mLiveableCards.setAdapter(mAdapter);
//
// return v;
// }
//
//
//
// }
| import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.loopj.android.http.JsonHttpResponseHandler;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import hack.com.househunt.R;
import hack.com.househunt.api.HouseHuntRestClient;
import hack.com.househunt.fragments.RecommendFragment; | package hack.com.househunt.internal;
/**
* Static helper methods used to reduce redundancy in the application.
*/
public class Util {
private Util() {
}
public static void switchFragments(FragmentActivity a, Fragment newFrag, String tag, boolean replace) {
FragmentTransaction ft = a.getSupportFragmentManager().beginTransaction().addToBackStack(tag);
ft.replace(R.id.container, newFrag, tag).commit();
Log.d(tag, "Switched to " + tag + " fragment");
}
public static void getRecommendation(final FragmentActivity a, final boolean switchToRecommend) {
String userId = UserSession.getInstance().getUserId(); | // Path: android/app/src/main/java/hack/com/househunt/api/HouseHuntRestClient.java
// public class HouseHuntRestClient {
//
// private static final String BASE_URL = "http://54.148.214.208:3000/api/";
//
// private static AsyncHttpClient client = new AsyncHttpClient();
//
// public static void get(String url, RequestParams params,
// AsyncHttpResponseHandler responseHandler) {
// client.get(getAbsoluteUrl(url), params, responseHandler);
// }
//
// public static void post(String url, StringEntity params,
// AsyncHttpResponseHandler responseHandler) {
// client.post(null, getAbsoluteUrl(url), params, "application/json", responseHandler);
// }
//
// private static String getAbsoluteUrl(String relativeUrl) {
// return BASE_URL + relativeUrl;
// }
//
// }
//
// Path: android/app/src/main/java/hack/com/househunt/fragments/RecommendFragment.java
// public class RecommendFragment extends Fragment {
//
// public static final String TAG = RecommendFragment.class.getSimpleName();
//
// @InjectView(R.id.card_stack) CardContainer mLiveableCards;
// private CardDataAdapter mAdapter;
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.recommend_frag, container, false);
// ButterKnife.inject(this, v);
// List<Liveable> liveables = UserSession.getInstance().getRecommendedLiveables();
// mAdapter = new CardDataAdapter(getActivity(), R.layout.liveable_card, liveables);
// mLiveableCards.setAdapter(mAdapter);
//
// return v;
// }
//
//
//
// }
// Path: android/app/src/main/java/hack/com/househunt/internal/Util.java
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.loopj.android.http.JsonHttpResponseHandler;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import hack.com.househunt.R;
import hack.com.househunt.api.HouseHuntRestClient;
import hack.com.househunt.fragments.RecommendFragment;
package hack.com.househunt.internal;
/**
* Static helper methods used to reduce redundancy in the application.
*/
public class Util {
private Util() {
}
public static void switchFragments(FragmentActivity a, Fragment newFrag, String tag, boolean replace) {
FragmentTransaction ft = a.getSupportFragmentManager().beginTransaction().addToBackStack(tag);
ft.replace(R.id.container, newFrag, tag).commit();
Log.d(tag, "Switched to " + tag + " fragment");
}
public static void getRecommendation(final FragmentActivity a, final boolean switchToRecommend) {
String userId = UserSession.getInstance().getUserId(); | HouseHuntRestClient.get("/rec/" + userId, null, new JsonHttpResponseHandler() { |
danfang/house-devs | android/app/src/main/java/hack/com/househunt/internal/Util.java | // Path: android/app/src/main/java/hack/com/househunt/api/HouseHuntRestClient.java
// public class HouseHuntRestClient {
//
// private static final String BASE_URL = "http://54.148.214.208:3000/api/";
//
// private static AsyncHttpClient client = new AsyncHttpClient();
//
// public static void get(String url, RequestParams params,
// AsyncHttpResponseHandler responseHandler) {
// client.get(getAbsoluteUrl(url), params, responseHandler);
// }
//
// public static void post(String url, StringEntity params,
// AsyncHttpResponseHandler responseHandler) {
// client.post(null, getAbsoluteUrl(url), params, "application/json", responseHandler);
// }
//
// private static String getAbsoluteUrl(String relativeUrl) {
// return BASE_URL + relativeUrl;
// }
//
// }
//
// Path: android/app/src/main/java/hack/com/househunt/fragments/RecommendFragment.java
// public class RecommendFragment extends Fragment {
//
// public static final String TAG = RecommendFragment.class.getSimpleName();
//
// @InjectView(R.id.card_stack) CardContainer mLiveableCards;
// private CardDataAdapter mAdapter;
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.recommend_frag, container, false);
// ButterKnife.inject(this, v);
// List<Liveable> liveables = UserSession.getInstance().getRecommendedLiveables();
// mAdapter = new CardDataAdapter(getActivity(), R.layout.liveable_card, liveables);
// mLiveableCards.setAdapter(mAdapter);
//
// return v;
// }
//
//
//
// }
| import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.loopj.android.http.JsonHttpResponseHandler;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import hack.com.househunt.R;
import hack.com.househunt.api.HouseHuntRestClient;
import hack.com.househunt.fragments.RecommendFragment; | package hack.com.househunt.internal;
/**
* Static helper methods used to reduce redundancy in the application.
*/
public class Util {
private Util() {
}
public static void switchFragments(FragmentActivity a, Fragment newFrag, String tag, boolean replace) {
FragmentTransaction ft = a.getSupportFragmentManager().beginTransaction().addToBackStack(tag);
ft.replace(R.id.container, newFrag, tag).commit();
Log.d(tag, "Switched to " + tag + " fragment");
}
public static void getRecommendation(final FragmentActivity a, final boolean switchToRecommend) {
String userId = UserSession.getInstance().getUserId();
HouseHuntRestClient.get("/rec/" + userId, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
Log.d("Util", "Get recommendation succeeded! Status code " + statusCode + "!");
UserSession.getInstance().setLiveable(response);
if (switchToRecommend) { | // Path: android/app/src/main/java/hack/com/househunt/api/HouseHuntRestClient.java
// public class HouseHuntRestClient {
//
// private static final String BASE_URL = "http://54.148.214.208:3000/api/";
//
// private static AsyncHttpClient client = new AsyncHttpClient();
//
// public static void get(String url, RequestParams params,
// AsyncHttpResponseHandler responseHandler) {
// client.get(getAbsoluteUrl(url), params, responseHandler);
// }
//
// public static void post(String url, StringEntity params,
// AsyncHttpResponseHandler responseHandler) {
// client.post(null, getAbsoluteUrl(url), params, "application/json", responseHandler);
// }
//
// private static String getAbsoluteUrl(String relativeUrl) {
// return BASE_URL + relativeUrl;
// }
//
// }
//
// Path: android/app/src/main/java/hack/com/househunt/fragments/RecommendFragment.java
// public class RecommendFragment extends Fragment {
//
// public static final String TAG = RecommendFragment.class.getSimpleName();
//
// @InjectView(R.id.card_stack) CardContainer mLiveableCards;
// private CardDataAdapter mAdapter;
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View v = inflater.inflate(R.layout.recommend_frag, container, false);
// ButterKnife.inject(this, v);
// List<Liveable> liveables = UserSession.getInstance().getRecommendedLiveables();
// mAdapter = new CardDataAdapter(getActivity(), R.layout.liveable_card, liveables);
// mLiveableCards.setAdapter(mAdapter);
//
// return v;
// }
//
//
//
// }
// Path: android/app/src/main/java/hack/com/househunt/internal/Util.java
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.loopj.android.http.JsonHttpResponseHandler;
import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import hack.com.househunt.R;
import hack.com.househunt.api.HouseHuntRestClient;
import hack.com.househunt.fragments.RecommendFragment;
package hack.com.househunt.internal;
/**
* Static helper methods used to reduce redundancy in the application.
*/
public class Util {
private Util() {
}
public static void switchFragments(FragmentActivity a, Fragment newFrag, String tag, boolean replace) {
FragmentTransaction ft = a.getSupportFragmentManager().beginTransaction().addToBackStack(tag);
ft.replace(R.id.container, newFrag, tag).commit();
Log.d(tag, "Switched to " + tag + " fragment");
}
public static void getRecommendation(final FragmentActivity a, final boolean switchToRecommend) {
String userId = UserSession.getInstance().getUserId();
HouseHuntRestClient.get("/rec/" + userId, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
Log.d("Util", "Get recommendation succeeded! Status code " + statusCode + "!");
UserSession.getInstance().setLiveable(response);
if (switchToRecommend) { | switchFragments(a, new RecommendFragment(), |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/debug/D.java | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
| import nl.arjanfrans.mario.MarioGame; | package nl.arjanfrans.mario.debug;
public class D {
public static void o(String msg) { | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
// Path: core/src/nl/arjanfrans/mario/debug/D.java
import nl.arjanfrans.mario.MarioGame;
package nl.arjanfrans.mario.debug;
public class D {
public static void o(String msg) { | if(MarioGame.DEBUG) { |
arjanfrans/mario-game | html/src/nl/arjanfrans/mario/client/HtmlLauncher.java | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
| import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame; | package nl.arjanfrans.mario.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(480, 320);
}
@Override
public ApplicationListener getApplicationListener () { | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
// Path: html/src/nl/arjanfrans/mario/client/HtmlLauncher.java
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame;
package nl.arjanfrans.mario.client;
public class HtmlLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
return new GwtApplicationConfiguration(480, 320);
}
@Override
public ApplicationListener getApplicationListener () { | return new MarioGame(); |
arjanfrans/mario-game | desktop/src/nl/arjanfrans/mario/desktop/DesktopLauncher.java | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
| import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame; | package nl.arjanfrans.mario.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
// Path: desktop/src/nl/arjanfrans/mario/desktop/DesktopLauncher.java
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame;
package nl.arjanfrans.mario.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); | new LwjglApplication(new MarioGame(), config); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/model/Super.java | // Path: core/src/nl/arjanfrans/mario/graphics/Tiles.java
// public class Tiles {
// private static TextureAtlas atlas = new TextureAtlas("data/tiles/mario_tileset.atlas");
//
// public static Array<StaticTiledMapTile> getAnimatedTile(String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// Array<StaticTiledMapTile> frames = new Array<StaticTiledMapTile>();
// for(int i = 0; i < regions.size; i++) {
// frames.add(new StaticTiledMapTile(regions.get(i)));
// }
// return frames;
// }
//
// public static Animation getAnimation(float speed, String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// TextureRegion[] frames = new TextureRegion[regions.size];
// for(int i = 0; i < regions.size; i++) {
// frames[i] = regions.get(i);
// }
// return new Animation(speed, frames);
// }
//
// public static TextureRegion getTile(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(ar.getRegionWidth(), ar.getRegionHeight())[0];
// return tr[0];
// }
//
// public static TextureRegion getTile8(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(8, 8)[0];
// return tr[0];
// }
//
// public void dispose() {
// atlas.dispose();
// }
//
// }
| import nl.arjanfrans.mario.graphics.Tiles;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle; | package nl.arjanfrans.mario.model;
public class Super extends Mushroom {
private static TextureRegion texture;
protected Rectangle rect = new Rectangle();
public Super (World world, float x, float y, float max_velocity) {
super(world, x, y, max_velocity); | // Path: core/src/nl/arjanfrans/mario/graphics/Tiles.java
// public class Tiles {
// private static TextureAtlas atlas = new TextureAtlas("data/tiles/mario_tileset.atlas");
//
// public static Array<StaticTiledMapTile> getAnimatedTile(String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// Array<StaticTiledMapTile> frames = new Array<StaticTiledMapTile>();
// for(int i = 0; i < regions.size; i++) {
// frames.add(new StaticTiledMapTile(regions.get(i)));
// }
// return frames;
// }
//
// public static Animation getAnimation(float speed, String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// TextureRegion[] frames = new TextureRegion[regions.size];
// for(int i = 0; i < regions.size; i++) {
// frames[i] = regions.get(i);
// }
// return new Animation(speed, frames);
// }
//
// public static TextureRegion getTile(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(ar.getRegionWidth(), ar.getRegionHeight())[0];
// return tr[0];
// }
//
// public static TextureRegion getTile8(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(8, 8)[0];
// return tr[0];
// }
//
// public void dispose() {
// atlas.dispose();
// }
//
// }
// Path: core/src/nl/arjanfrans/mario/model/Super.java
import nl.arjanfrans.mario.graphics.Tiles;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
package nl.arjanfrans.mario.model;
public class Super extends Mushroom {
private static TextureRegion texture;
protected Rectangle rect = new Rectangle();
public Super (World world, float x, float y, float max_velocity) {
super(world, x, y, max_velocity); | texture = Tiles.getTile("mushroom_super"); |
arjanfrans/mario-game | ios/src/nl/arjanfrans/mario/IOSLauncher.java | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
| import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.uikit.UIApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame; | package nl.arjanfrans.mario;
public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration(); | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
// Path: ios/src/nl/arjanfrans/mario/IOSLauncher.java
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.uikit.UIApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame;
package nl.arjanfrans.mario;
public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration(); | return new IOSApplication(new MarioGame(), config); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/model/Mushroom.java | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
| import nl.arjanfrans.mario.actions.MoveableActions;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.actions.Actions; | package nl.arjanfrans.mario.model;
public abstract class Mushroom extends MovingActor {
public Mushroom(World world, float x, float y, float max_velocity) {
super(world, x, y, max_velocity);
}
public void appear() {
this.setVisible(true);
this.addAction(Actions.sequence(Actions.moveTo(this.getX(), this.getY() + this.getHeight(), | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
// Path: core/src/nl/arjanfrans/mario/model/Mushroom.java
import nl.arjanfrans.mario.actions.MoveableActions;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
package nl.arjanfrans.mario.model;
public abstract class Mushroom extends MovingActor {
public Mushroom(World world, float x, float y, float max_velocity) {
super(world, x, y, max_velocity);
}
public void appear() {
this.setVisible(true);
this.addAction(Actions.sequence(Actions.moveTo(this.getX(), this.getY() + this.getHeight(), | 0.3f, Interpolation.linear), MoveableActions.startMovingAction(this))); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/model/Flag.java | // Path: core/src/nl/arjanfrans/mario/graphics/Tiles.java
// public class Tiles {
// private static TextureAtlas atlas = new TextureAtlas("data/tiles/mario_tileset.atlas");
//
// public static Array<StaticTiledMapTile> getAnimatedTile(String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// Array<StaticTiledMapTile> frames = new Array<StaticTiledMapTile>();
// for(int i = 0; i < regions.size; i++) {
// frames.add(new StaticTiledMapTile(regions.get(i)));
// }
// return frames;
// }
//
// public static Animation getAnimation(float speed, String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// TextureRegion[] frames = new TextureRegion[regions.size];
// for(int i = 0; i < regions.size; i++) {
// frames[i] = regions.get(i);
// }
// return new Animation(speed, frames);
// }
//
// public static TextureRegion getTile(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(ar.getRegionWidth(), ar.getRegionHeight())[0];
// return tr[0];
// }
//
// public static TextureRegion getTile8(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(8, 8)[0];
// return tr[0];
// }
//
// public void dispose() {
// atlas.dispose();
// }
//
// }
| import nl.arjanfrans.mario.graphics.Tiles;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.actions.Actions; | package nl.arjanfrans.mario.model;
public class Flag extends Actor {
private Animation animation;
private float stateTime;
private float endX;
private float endY;
private boolean down = false;
private float bottomY;
private float slideOffset = 2;
public Flag(float x, float y, float width, float height, float endX, float endY) { | // Path: core/src/nl/arjanfrans/mario/graphics/Tiles.java
// public class Tiles {
// private static TextureAtlas atlas = new TextureAtlas("data/tiles/mario_tileset.atlas");
//
// public static Array<StaticTiledMapTile> getAnimatedTile(String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// Array<StaticTiledMapTile> frames = new Array<StaticTiledMapTile>();
// for(int i = 0; i < regions.size; i++) {
// frames.add(new StaticTiledMapTile(regions.get(i)));
// }
// return frames;
// }
//
// public static Animation getAnimation(float speed, String name) {
// Array<AtlasRegion> regions = atlas.findRegions(name);
// TextureRegion[] frames = new TextureRegion[regions.size];
// for(int i = 0; i < regions.size; i++) {
// frames[i] = regions.get(i);
// }
// return new Animation(speed, frames);
// }
//
// public static TextureRegion getTile(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(ar.getRegionWidth(), ar.getRegionHeight())[0];
// return tr[0];
// }
//
// public static TextureRegion getTile8(String name) {
// AtlasRegion ar = atlas.findRegion(name);
// TextureRegion[] tr = ar.split(8, 8)[0];
// return tr[0];
// }
//
// public void dispose() {
// atlas.dispose();
// }
//
// }
// Path: core/src/nl/arjanfrans/mario/model/Flag.java
import nl.arjanfrans.mario.graphics.Tiles;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
package nl.arjanfrans.mario.model;
public class Flag extends Actor {
private Animation animation;
private float stateTime;
private float endX;
private float endY;
private boolean down = false;
private float bottomY;
private float slideOffset = 2;
public Flag(float x, float y, float width, float height, float endX, float endY) { | animation = Tiles.getAnimation(0.15f, "evil_flag"); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/model/Goomba.java | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
//
// Path: core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java
// public class GoombaAnimation extends CharacterAnimation {
// private Animation walking;
// private Animation trampled;
//
// public GoombaAnimation() {
// Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
// walking = new Animation(0.2f, regions);
// walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
//
// trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
// }
//
// public Animation getAnimation(State state) {
// switch(state) {
// case Walking:
// return walking;
// case Dying:
// return trampled;
// default:
// return walking;
// }
// }
//
// public Vector2 getDimensions(State state) {
// switch(state) {
// case Walking:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// case Dying:
// return new Vector2(trampled.getKeyFrame(0).getRegionWidth() * scale,
// trampled.getKeyFrame(0).getRegionHeight() * scale);
// default:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// }
// }
//
//
// }
| import nl.arjanfrans.mario.actions.MoveableActions;
import nl.arjanfrans.mario.graphics.GoombaAnimation;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.Array; | package nl.arjanfrans.mario.model;
public class Goomba extends Creature {
protected float max_velocity = 1f; | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
//
// Path: core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java
// public class GoombaAnimation extends CharacterAnimation {
// private Animation walking;
// private Animation trampled;
//
// public GoombaAnimation() {
// Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
// walking = new Animation(0.2f, regions);
// walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
//
// trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
// }
//
// public Animation getAnimation(State state) {
// switch(state) {
// case Walking:
// return walking;
// case Dying:
// return trampled;
// default:
// return walking;
// }
// }
//
// public Vector2 getDimensions(State state) {
// switch(state) {
// case Walking:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// case Dying:
// return new Vector2(trampled.getKeyFrame(0).getRegionWidth() * scale,
// trampled.getKeyFrame(0).getRegionHeight() * scale);
// default:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// }
// }
//
//
// }
// Path: core/src/nl/arjanfrans/mario/model/Goomba.java
import nl.arjanfrans.mario.actions.MoveableActions;
import nl.arjanfrans.mario.graphics.GoombaAnimation;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.Array;
package nl.arjanfrans.mario.model;
public class Goomba extends Creature {
protected float max_velocity = 1f; | protected GoombaAnimation gfx = new GoombaAnimation(); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/model/Goomba.java | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
//
// Path: core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java
// public class GoombaAnimation extends CharacterAnimation {
// private Animation walking;
// private Animation trampled;
//
// public GoombaAnimation() {
// Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
// walking = new Animation(0.2f, regions);
// walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
//
// trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
// }
//
// public Animation getAnimation(State state) {
// switch(state) {
// case Walking:
// return walking;
// case Dying:
// return trampled;
// default:
// return walking;
// }
// }
//
// public Vector2 getDimensions(State state) {
// switch(state) {
// case Walking:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// case Dying:
// return new Vector2(trampled.getKeyFrame(0).getRegionWidth() * scale,
// trampled.getKeyFrame(0).getRegionHeight() * scale);
// default:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// }
// }
//
//
// }
| import nl.arjanfrans.mario.actions.MoveableActions;
import nl.arjanfrans.mario.graphics.GoombaAnimation;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.Array; | package nl.arjanfrans.mario.model;
public class Goomba extends Creature {
protected float max_velocity = 1f;
protected GoombaAnimation gfx = new GoombaAnimation();
protected Rectangle rect = new Rectangle();
public Goomba(World world, float positionX, float positionY) {
super(world, positionX, positionY, 3f);
float width = gfx.getDimensions(state).x;;
float height = gfx.getDimensions(state).y;
this.setSize(width, height);
direction = Direction.LEFT;
moving = false;
}
private void dieByTrample() {
state = State.Dying;
velocity.set(0, 0);
this.addAction(Actions.sequence(Actions.moveBy(0, -(2 * 1/16f) ),
Actions.delay(0.5f), | // Path: core/src/nl/arjanfrans/mario/actions/MoveableActions.java
// public class MoveableActions extends Actions {
//
// public static Action DieAction(Actor actor) {
// return new Die(actor);
// }
//
// static public class Die extends Action {
// private Actor actor;
//
// public Die(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setDead(true);
// return true;
// }
// }
//
// public static Action startMovingAction(Actor actor) {
// return new startMoving(actor);
// }
//
// static public class startMoving extends Action {
// public startMoving(Actor actor) {
// this.actor = actor;
// }
//
// public boolean act(float delta) {
// ((MovingActor) actor).setMoving(true);
// return true;
// }
// }
//
// }
//
// Path: core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java
// public class GoombaAnimation extends CharacterAnimation {
// private Animation walking;
// private Animation trampled;
//
// public GoombaAnimation() {
// Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
// walking = new Animation(0.2f, regions);
// walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
//
// trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
// }
//
// public Animation getAnimation(State state) {
// switch(state) {
// case Walking:
// return walking;
// case Dying:
// return trampled;
// default:
// return walking;
// }
// }
//
// public Vector2 getDimensions(State state) {
// switch(state) {
// case Walking:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// case Dying:
// return new Vector2(trampled.getKeyFrame(0).getRegionWidth() * scale,
// trampled.getKeyFrame(0).getRegionHeight() * scale);
// default:
// return new Vector2(walking.getKeyFrame(0).getRegionWidth() * scale,
// walking.getKeyFrame(0).getRegionHeight() * scale);
// }
// }
//
//
// }
// Path: core/src/nl/arjanfrans/mario/model/Goomba.java
import nl.arjanfrans.mario.actions.MoveableActions;
import nl.arjanfrans.mario.graphics.GoombaAnimation;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.Array;
package nl.arjanfrans.mario.model;
public class Goomba extends Creature {
protected float max_velocity = 1f;
protected GoombaAnimation gfx = new GoombaAnimation();
protected Rectangle rect = new Rectangle();
public Goomba(World world, float positionX, float positionY) {
super(world, positionX, positionY, 3f);
float width = gfx.getDimensions(state).x;;
float height = gfx.getDimensions(state).y;
this.setSize(width, height);
direction = Direction.LEFT;
moving = false;
}
private void dieByTrample() {
state = State.Dying;
velocity.set(0, 0);
this.addAction(Actions.sequence(Actions.moveBy(0, -(2 * 1/16f) ),
Actions.delay(0.5f), | MoveableActions.DieAction(this))); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java | // Path: core/src/nl/arjanfrans/mario/model/MovingActor.java
// public static enum State {
//
// Standing, Walking, Jumping, Dying, Dead, FlagSlide, NoControl, Pose
// }
| import nl.arjanfrans.mario.model.MovingActor.State;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array; | package nl.arjanfrans.mario.graphics;
public class GoombaAnimation extends CharacterAnimation {
private Animation walking;
private Animation trampled;
public GoombaAnimation() {
Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
walking = new Animation(0.2f, regions);
walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
}
| // Path: core/src/nl/arjanfrans/mario/model/MovingActor.java
// public static enum State {
//
// Standing, Walking, Jumping, Dying, Dead, FlagSlide, NoControl, Pose
// }
// Path: core/src/nl/arjanfrans/mario/graphics/GoombaAnimation.java
import nl.arjanfrans.mario.model.MovingActor.State;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
package nl.arjanfrans.mario.graphics;
public class GoombaAnimation extends CharacterAnimation {
private Animation walking;
private Animation trampled;
public GoombaAnimation() {
Array<AtlasRegion> regions = atlas.findRegions("goomba_walking");
walking = new Animation(0.2f, regions);
walking.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
trampled = new Animation(1f, atlas.findRegion("goomba_trampled"));
}
| public Animation getAnimation(State state) { |
arjanfrans/mario-game | android/src/nl/arjanfrans/mario/android/AndroidLauncher.java | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
| import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame; | package nl.arjanfrans.mario.android;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); | // Path: core/src/nl/arjanfrans/mario/MarioGame.java
// public class MarioGame extends Game {
// private World world;
// public static final String VERSION = "0.01";
// public static final boolean DEBUG = true;
// public static final int FPS = 60;
//
// @Override
// public void create()
// {
// world = new World();
// }
// @Override
// public void dispose() {
// world.dispose();
// }
//
// @Override
// public void resize(int width, int height)
// {
// world.getRenderer().resize(width, height);
// }
//
// @Override
// public void pause()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void resume()
// {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public void render() {
// //super.render();
//
// world.update();
// }
// }
// Path: android/src/nl/arjanfrans/mario/android/AndroidLauncher.java
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import nl.arjanfrans.mario.MarioGame;
package nl.arjanfrans.mario.android;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); | initialize(new MarioGame(), config); |
arjanfrans/mario-game | core/src/nl/arjanfrans/mario/graphics/MarioAnimation.java | // Path: core/src/nl/arjanfrans/mario/model/MovingActor.java
// public static enum State {
//
// Standing, Walking, Jumping, Dying, Dead, FlagSlide, NoControl, Pose
// }
| import nl.arjanfrans.mario.model.MovingActor.State;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array; |
dying = new Animation(0, atlas.findRegion("mario_mini_dead"));
// For animation with more than 1 frames use 'regions = atlas.findRegions("...").
regions = atlas.findRegions("mario_big_walking");
standing_big = new Animation(0, regions.get(0));
walking_big = new Animation(0.1f, regions);
walking_big.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
jumping_big = new Animation(0, atlas.findRegion("mario_big_jump"));
crouch_big = new Animation(0, atlas.findRegion("mario_big_crouch"));
regions = atlas.findRegions("mario_big_flagslide");
flagslide_big = new Animation(1f, regions);
regions = atlas.findRegions("mario_mini_flagslide");
flagslide_small = new Animation(1f, regions);
regions = atlas.findRegions("mario_big_pose");
pose_big = new Animation(3.5f, regions);
//TODO add mini mario pose
regions = atlas.findRegions("mario_mini_jump");
pose_small = new Animation(3.5f, regions);
}
| // Path: core/src/nl/arjanfrans/mario/model/MovingActor.java
// public static enum State {
//
// Standing, Walking, Jumping, Dying, Dead, FlagSlide, NoControl, Pose
// }
// Path: core/src/nl/arjanfrans/mario/graphics/MarioAnimation.java
import nl.arjanfrans.mario.model.MovingActor.State;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
dying = new Animation(0, atlas.findRegion("mario_mini_dead"));
// For animation with more than 1 frames use 'regions = atlas.findRegions("...").
regions = atlas.findRegions("mario_big_walking");
standing_big = new Animation(0, regions.get(0));
walking_big = new Animation(0.1f, regions);
walking_big.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
jumping_big = new Animation(0, atlas.findRegion("mario_big_jump"));
crouch_big = new Animation(0, atlas.findRegion("mario_big_crouch"));
regions = atlas.findRegions("mario_big_flagslide");
flagslide_big = new Animation(1f, regions);
regions = atlas.findRegions("mario_mini_flagslide");
flagslide_small = new Animation(1f, regions);
regions = atlas.findRegions("mario_big_pose");
pose_big = new Animation(3.5f, regions);
//TODO add mini mario pose
regions = atlas.findRegions("mario_mini_jump");
pose_small = new Animation(3.5f, regions);
}
| public Animation getAnimation(State state, int level) { |
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/LexState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
| import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable; |
final static Hashtable<String, Integer> RESERVED = new Hashtable<String, Integer>();
static {
for ( int i=0; i<NUM_RESERVED; i++ ) {
String ts = luaX_tokens[i];
RESERVED.put(ts, new Integer(FIRST_RESERVED+i));
}
}
private boolean isalnum(int c) {
return (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c == '_');
// return Character.isLetterOrDigit(c);
}
private boolean isalpha(int c) {
return (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z');
}
private boolean isdigit(int c) {
return (c >= '0' && c <= '9');
}
private boolean isspace(int c) {
return (c <= ' ');
}
| // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
// Path: engine/hu/mentlerd/hybrid/compiler/LexState.java
import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable;
final static Hashtable<String, Integer> RESERVED = new Hashtable<String, Integer>();
static {
for ( int i=0; i<NUM_RESERVED; i++ ) {
String ts = luaX_tokens[i];
RESERVED.put(ts, new Integer(FIRST_RESERVED+i));
}
}
private boolean isalnum(int c) {
return (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c == '_');
// return Character.isLetterOrDigit(c);
}
private boolean isalpha(int c) {
return (c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z');
}
private boolean isdigit(int c) {
return (c >= '0' && c <= '9');
}
private boolean isspace(int c) {
return (c <= ' ');
}
| public static Prototype compile(int firstByte, Reader z, String source) { |
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/LexState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
| import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable; | "char("+((int)token)+")":
String.valueOf( (char) token );
} else {
return luaX_tokens[token-FIRST_RESERVED];
}
}
private static boolean iscntrl(int token) {
return token < ' ';
}
String txtToken(int token) {
switch ( token ) {
case TK_NAME:
case TK_STRING:
case TK_NUMBER:
return new String( buff, 0, nbuff );
default:
return token2str( token );
}
}
void lexerror( String msg, int token ) {
String cid = source;
String errorMessage;
if ( token != 0 ) {
errorMessage = cid+":"+linenumber+": "+msg+" near '"+txtToken(token) + "'";
} else {
errorMessage = cid+":"+linenumber+": "+msg;
} | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
// Path: engine/hu/mentlerd/hybrid/compiler/LexState.java
import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable;
"char("+((int)token)+")":
String.valueOf( (char) token );
} else {
return luaX_tokens[token-FIRST_RESERVED];
}
}
private static boolean iscntrl(int token) {
return token < ' ';
}
String txtToken(int token) {
switch ( token ) {
case TK_NAME:
case TK_STRING:
case TK_NUMBER:
return new String( buff, 0, nbuff );
default:
return token2str( token );
}
}
void lexerror( String msg, int token ) {
String cid = source;
String errorMessage;
if ( token != 0 ) {
errorMessage = cid+":"+linenumber+": "+msg+" near '"+txtToken(token) + "'";
} else {
errorMessage = cid+":"+linenumber+": "+msg;
} | throw new LuaException(errorMessage); |
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/LexState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
| import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable; | + " expected " + "(to close " + LUA_QS(token2str(who))
+ " at line " + where + ")");
}
}
}
String str_checkname() {
String ts;
check(TK_NAME);
ts = t.ts;
next();
return ts;
}
void codestring(ExpDesc e, String s) {
e.init(VK, fs.stringK(s));
}
void checkname(ExpDesc e) {
codestring(e, str_checkname());
}
int registerlocalvar(String varname) {
FuncState fs = this.fs;
Prototype f = fs.f;
if (f.locals == null || fs.nlocvars + 1 > f.locals.length)
f.locals = FuncState.realloc( f.locals, fs.nlocvars*2+1 );
| // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
// Path: engine/hu/mentlerd/hybrid/compiler/LexState.java
import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable;
+ " expected " + "(to close " + LUA_QS(token2str(who))
+ " at line " + where + ")");
}
}
}
String str_checkname() {
String ts;
check(TK_NAME);
ts = t.ts;
next();
return ts;
}
void codestring(ExpDesc e, String s) {
e.init(VK, fs.stringK(s));
}
void checkname(ExpDesc e) {
codestring(e, str_checkname());
}
int registerlocalvar(String varname) {
FuncState fs = this.fs;
Prototype f = fs.f;
if (f.locals == null || fs.nlocvars + 1 > f.locals.length)
f.locals = FuncState.realloc( f.locals, fs.nlocvars*2+1 );
| f.locals[fs.nlocvars] = new LocalVar(varname); |
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/LexState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
| import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable; | }
void expr(ExpDesc v) {
this.subexpr(v, 0);
}
/* }==================================================================== */
/*
** {======================================================================
** Rules for Statements
** =======================================================================
*/
boolean block_follow (int token) {
switch (token) {
case TK_ELSE: case TK_ELSEIF: case TK_END:
case TK_UNTIL: case TK_EOS:
return true;
default: return false;
}
}
void block () {
/* block -> chunk */
FuncState fs = this.fs; | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/compiler/BlockCnt.java
// public class BlockCnt {
// BlockCnt previous; /* chain */
// int breaklist; /* list of jumps out of this loop */
// int nactvar; /* # active locals outside the breakable structure */
// boolean upval; /* true if some variable in the block is an upvalue */
// boolean isbreakable; /* true if `block' is a loop */
// }
// Path: engine/hu/mentlerd/hybrid/compiler/LexState.java
import hu.mentlerd.hybrid.LuaException;
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import hu.mentlerd.hybrid.compiler.BlockCnt;
import java.io.IOException;
import java.io.Reader;
import java.util.Hashtable;
}
void expr(ExpDesc v) {
this.subexpr(v, 0);
}
/* }==================================================================== */
/*
** {======================================================================
** Rules for Statements
** =======================================================================
*/
boolean block_follow (int token) {
switch (token) {
case TK_ELSE: case TK_ELSEIF: case TK_END:
case TK_UNTIL: case TK_EOS:
return true;
default: return false;
}
}
void block () {
/* block -> chunk */
FuncState fs = this.fs; | BlockCnt bl = new BlockCnt(); |
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/FuncState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
| import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
| /*******************************************************************************
* Copyright (c) 2007 LuaJ. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package hu.mentlerd.hybrid.compiler;
/**
* @exclude
*/
public class FuncState {
private static final Object NULL_OBJECT = new Object();
/* upvalue names */
// public String[] upvalues;
public int linedefined;
public int lastlinedefined;
public int isVararg;
| // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
// Path: engine/hu/mentlerd/hybrid/compiler/FuncState.java
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
/*******************************************************************************
* Copyright (c) 2007 LuaJ. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package hu.mentlerd.hybrid.compiler;
/**
* @exclude
*/
public class FuncState {
private static final Object NULL_OBJECT = new Object();
/* upvalue names */
// public String[] upvalues;
public int linedefined;
public int lastlinedefined;
public int isVararg;
| Prototype f; /* current function header */
|
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/FuncState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
| import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
| this.htable = new Hashtable<Object, Integer>();
}
// =============================================================
// from lcode.h
// =============================================================
InstructionPtr getcodePtr(ExpDesc e) {
return new InstructionPtr( f.code, e.info );
}
int getcode(ExpDesc e) {
return f.code[e.info];
}
int codeAsBx(int o, int A, int sBx) {
return codeABx(o,A,sBx+MAXARG_sBx);
}
void setmultret(ExpDesc e) {
setreturns(e, LUA_MULTRET);
}
// =============================================================
// from lparser.c
// =============================================================
| // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
// Path: engine/hu/mentlerd/hybrid/compiler/FuncState.java
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
this.htable = new Hashtable<Object, Integer>();
}
// =============================================================
// from lcode.h
// =============================================================
InstructionPtr getcodePtr(ExpDesc e) {
return new InstructionPtr( f.code, e.info );
}
int getcode(ExpDesc e) {
return f.code[e.info];
}
int codeAsBx(int o, int A, int sBx) {
return codeABx(o,A,sBx+MAXARG_sBx);
}
void setmultret(ExpDesc e) {
setreturns(e, LUA_MULTRET);
}
// =============================================================
// from lparser.c
// =============================================================
| LocalVar getlocvar(int i) {
|
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/compiler/FuncState.java | // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
| import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
| int codeABC(int o, int a, int b, int c) {
_assert (getOpMode(o) == iABC);
_assert (getBMode(o) != OpArgN || b == 0);
_assert (getCMode(o) != OpArgN || c == 0);
return this.code(CREATE_ABC(o, a, b, c), this.ls.lastline);
}
int codeABx(int o, int a, int bc) {
_assert (getOpMode(o) == iABx || getOpMode(o) == iAsBx);
_assert (getCMode(o) == OpArgN);
return this.code(CREATE_ABx(o, a, bc), this.ls.lastline);
}
void setlist(int base, int nelems, int tostore) {
int c = (nelems - 1) / LFIELDS_PER_FLUSH + 1;
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
_assert (tostore != 0);
if (c <= MAXARG_C)
this.codeABC(OP_SETLIST, base, b, c);
else {
this.codeABC(OP_SETLIST, base, b, 0);
this.code(c, this.ls.lastline);
}
this.freereg = base + 1; /* free registers with list values */
}
protected static void _assert(boolean b) {
if (!b)
| // Path: engine/hu/mentlerd/hybrid/LuaException.java
// public class LuaException extends RuntimeException{
// private static final long serialVersionUID = -8214311557059032574L;
//
// private Object luaCause;
//
// public LuaException( String message ) {
// super( message );
// }
//
// public LuaException( String message, Object cause ){
// super( message );
// this.luaCause = cause;
// }
//
// public LuaException( Throwable cause ){
// super(cause);
// }
//
// public Object getLuaCause(){
// if ( luaCause == null )
// return getMessage();
//
// return luaCause;
// }
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public final class Prototype {
//
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
//
// public int[] code;
//
// public Object[] constants;
// public Prototype[] prototypes;
//
// public int numParams;
// public boolean isVararg;
//
// public int numUpvalues;
// public int maxStacksize;
//
// public String source;
//
// //Debug info
// public int[] lines;
// public LocalVar[] locals;
// public String[] upvalues;
//
// //Debug helper
// public String findLocalName( int slot, int pc ){
// for ( int index = 0; index < locals.length; index++ ){
// LocalVar local = locals[index];
//
// if ( local.start > pc )
// break;
//
// if ( local.end >= pc && slot-- == 0 )
// return local.name;
// }
//
// return null;
// }
//
// }
//
// Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
// Path: engine/hu/mentlerd/hybrid/compiler/FuncState.java
import hu.mentlerd.hybrid.Prototype;
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.util.Hashtable;
import hu.mentlerd.hybrid.LuaException;
int codeABC(int o, int a, int b, int c) {
_assert (getOpMode(o) == iABC);
_assert (getBMode(o) != OpArgN || b == 0);
_assert (getCMode(o) != OpArgN || c == 0);
return this.code(CREATE_ABC(o, a, b, c), this.ls.lastline);
}
int codeABx(int o, int a, int bc) {
_assert (getOpMode(o) == iABx || getOpMode(o) == iAsBx);
_assert (getCMode(o) == OpArgN);
return this.code(CREATE_ABx(o, a, bc), this.ls.lastline);
}
void setlist(int base, int nelems, int tostore) {
int c = (nelems - 1) / LFIELDS_PER_FLUSH + 1;
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
_assert (tostore != 0);
if (c <= MAXARG_C)
this.codeABC(OP_SETLIST, base, b, c);
else {
this.codeABC(OP_SETLIST, base, b, 0);
this.code(c, this.ls.lastline);
}
this.freereg = base + 1; /* free registers with list values */
}
protected static void _assert(boolean b) {
if (!b)
| throw new LuaException("compiler assert failed");
|
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/BytecodeManager.java | // Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
| import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
| } else if ( value instanceof Double ){
stream.write(TYPE_NUMBER);
stream.writeLong( Double.doubleToLongBits((Double) value) );
} else if ( value instanceof String ){
stream.write(TYPE_STRING);
dump(stream, (String) value);
} else {
throw new RuntimeException("Bad constant in constant pool");
}
}
//Write protos
length = proto.prototypes.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ )
dump(stream, proto.prototypes[index]);
//Line info
length = proto.lines.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ )
stream.writeInt( proto.lines[index] );
//Local values
length = proto.locals.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ ){
| // Path: engine/hu/mentlerd/hybrid/Prototype.java
// public static class LocalVar {
// public String name;
//
// public int start;
// public int end;
//
// public LocalVar(String name) {
// this.name = name;
// }
// public LocalVar(String name, int start, int end){
// this.name = name;
//
// this.start = start;
// this.end = end;
// }
// }
// Path: engine/hu/mentlerd/hybrid/BytecodeManager.java
import hu.mentlerd.hybrid.Prototype.LocalVar;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
} else if ( value instanceof Double ){
stream.write(TYPE_NUMBER);
stream.writeLong( Double.doubleToLongBits((Double) value) );
} else if ( value instanceof String ){
stream.write(TYPE_STRING);
dump(stream, (String) value);
} else {
throw new RuntimeException("Bad constant in constant pool");
}
}
//Write protos
length = proto.prototypes.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ )
dump(stream, proto.prototypes[index]);
//Line info
length = proto.lines.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ )
stream.writeInt( proto.lines[index] );
//Local values
length = proto.locals.length;
stream.writeInt(length);
for ( int index = 0; index < length; index++ ){
| LocalVar local = proto.locals[index];
|
mentlerd/HybridVM | engine/hu/mentlerd/hybrid/LuaUtil.java | // Path: engine/hu/mentlerd/hybrid/LuaOpcodes.java
// public class LuaOpcodes {
//
// public static final int FIELDS_PER_FLUSH = 50;
//
// public static final int OP_MOVE = 0;
//
// public static final int OP_LOADK = 1;
// public static final int OP_LOADBOOL = 2;
// public static final int OP_LOADNIL = 3;
//
// public static final int OP_GETUPVAL = 4;
// public static final int OP_GETGLOBAL = 5;
// public static final int OP_GETTABLE = 6;
// public static final int OP_SETGLOBAL = 7;
// public static final int OP_SETUPVAL = 8;
// public static final int OP_SETTABLE = 9;
//
// public static final int OP_NEWTABLE = 10;
//
// public static final int OP_SELF = 11;
//
// public static final int OP_ADD = 12;
// public static final int OP_SUB = 13;
// public static final int OP_MUL = 14;
// public static final int OP_DIV = 15;
// public static final int OP_MOD = 16;
// public static final int OP_POW = 17;
// public static final int OP_UNM = 18;
// public static final int OP_NOT = 19;
// public static final int OP_LEN = 20;
//
// public static final int OP_CONCAT = 21;
//
// public static final int OP_JMP = 22;
//
// public static final int OP_EQ = 23;
// public static final int OP_LT = 24;
// public static final int OP_LE = 25;
//
// public static final int OP_TEST = 26;
// public static final int OP_TESTSET = 27;
//
// public static final int OP_CALL = 28;
// public static final int OP_TAILCALL = 29;
//
// public static final int OP_RETURN = 30;
//
// public static final int OP_FORLOOP = 31;
// public static final int OP_FORPREP = 32;
// public static final int OP_TFORLOOP = 33;
//
// public static final int OP_SETLIST = 34;
// public static final int OP_CLOSE = 35;
// public static final int OP_CLOSURE = 36;
// public static final int OP_VARARG = 37;
//
// public static int getOp(int code) {
// return code & 63;
// }
//
// public static final int getA8(int op) {
// return (op >>> 6) & 255;
// }
//
// public static final int getC9(int op) {
// return (op >>> 14) & 511;
// }
//
// public static final int getB9(int op) {
// return (op >>> 23) & 511;
// }
//
// public static final int getBx(int op) {
// return (op >>> 14);
// }
//
// public static final int getSBx(int op) {
// return (op >>> 14) - 131071;
// }
//
// //Meta operator names
// protected static final int META_OP_OFFSET = OP_ADD;
// protected static final int META_OP_COUNT = OP_LE - OP_ADD +1;
//
// private static final String opMetaNames[] = new String[META_OP_COUNT];
//
// static {
// setMetaOp(OP_ADD, "__add");
// setMetaOp(OP_SUB, "__sub");
// setMetaOp(OP_MUL, "__mul");
// setMetaOp(OP_DIV, "__div");
// setMetaOp(OP_MOD, "__mod");
// setMetaOp(OP_POW, "__POW");
//
// setMetaOp(OP_EQ, "__eq");
// setMetaOp(OP_LT, "__lt");
// setMetaOp(OP_LE, "__le");
// }
//
// private static void setMetaOp( int op, String meta ){
// opMetaNames[op -META_OP_OFFSET] = meta;
// }
// public static String getMetaOp( int op ){
// return opMetaNames[op -META_OP_OFFSET];
// }
//
// }
| import static hu.mentlerd.hybrid.LuaOpcodes.*;
import java.util.Arrays;
import java.util.Comparator;
| return value.toString();
return null;
}
/*
* Sorting
*/
protected static class LuaComparator implements Comparator<Object>{
protected LuaThread thread;
protected Object comparator;
protected boolean order;
public LuaComparator( LuaThread thread, Object func, boolean desc ){
this.thread = thread;
this.comparator = func;
this.order = desc;
}
public int compare( Object A, Object B ) {
if ( A == null ) return 1;
if ( B == null ) return -1;
boolean isLess;
if ( comparator != null ){
isLess = LuaUtil.toBoolean( thread.call(comparator, A, B) );
} else {
| // Path: engine/hu/mentlerd/hybrid/LuaOpcodes.java
// public class LuaOpcodes {
//
// public static final int FIELDS_PER_FLUSH = 50;
//
// public static final int OP_MOVE = 0;
//
// public static final int OP_LOADK = 1;
// public static final int OP_LOADBOOL = 2;
// public static final int OP_LOADNIL = 3;
//
// public static final int OP_GETUPVAL = 4;
// public static final int OP_GETGLOBAL = 5;
// public static final int OP_GETTABLE = 6;
// public static final int OP_SETGLOBAL = 7;
// public static final int OP_SETUPVAL = 8;
// public static final int OP_SETTABLE = 9;
//
// public static final int OP_NEWTABLE = 10;
//
// public static final int OP_SELF = 11;
//
// public static final int OP_ADD = 12;
// public static final int OP_SUB = 13;
// public static final int OP_MUL = 14;
// public static final int OP_DIV = 15;
// public static final int OP_MOD = 16;
// public static final int OP_POW = 17;
// public static final int OP_UNM = 18;
// public static final int OP_NOT = 19;
// public static final int OP_LEN = 20;
//
// public static final int OP_CONCAT = 21;
//
// public static final int OP_JMP = 22;
//
// public static final int OP_EQ = 23;
// public static final int OP_LT = 24;
// public static final int OP_LE = 25;
//
// public static final int OP_TEST = 26;
// public static final int OP_TESTSET = 27;
//
// public static final int OP_CALL = 28;
// public static final int OP_TAILCALL = 29;
//
// public static final int OP_RETURN = 30;
//
// public static final int OP_FORLOOP = 31;
// public static final int OP_FORPREP = 32;
// public static final int OP_TFORLOOP = 33;
//
// public static final int OP_SETLIST = 34;
// public static final int OP_CLOSE = 35;
// public static final int OP_CLOSURE = 36;
// public static final int OP_VARARG = 37;
//
// public static int getOp(int code) {
// return code & 63;
// }
//
// public static final int getA8(int op) {
// return (op >>> 6) & 255;
// }
//
// public static final int getC9(int op) {
// return (op >>> 14) & 511;
// }
//
// public static final int getB9(int op) {
// return (op >>> 23) & 511;
// }
//
// public static final int getBx(int op) {
// return (op >>> 14);
// }
//
// public static final int getSBx(int op) {
// return (op >>> 14) - 131071;
// }
//
// //Meta operator names
// protected static final int META_OP_OFFSET = OP_ADD;
// protected static final int META_OP_COUNT = OP_LE - OP_ADD +1;
//
// private static final String opMetaNames[] = new String[META_OP_COUNT];
//
// static {
// setMetaOp(OP_ADD, "__add");
// setMetaOp(OP_SUB, "__sub");
// setMetaOp(OP_MUL, "__mul");
// setMetaOp(OP_DIV, "__div");
// setMetaOp(OP_MOD, "__mod");
// setMetaOp(OP_POW, "__POW");
//
// setMetaOp(OP_EQ, "__eq");
// setMetaOp(OP_LT, "__lt");
// setMetaOp(OP_LE, "__le");
// }
//
// private static void setMetaOp( int op, String meta ){
// opMetaNames[op -META_OP_OFFSET] = meta;
// }
// public static String getMetaOp( int op ){
// return opMetaNames[op -META_OP_OFFSET];
// }
//
// }
// Path: engine/hu/mentlerd/hybrid/LuaUtil.java
import static hu.mentlerd.hybrid.LuaOpcodes.*;
import java.util.Arrays;
import java.util.Comparator;
return value.toString();
return null;
}
/*
* Sorting
*/
protected static class LuaComparator implements Comparator<Object>{
protected LuaThread thread;
protected Object comparator;
protected boolean order;
public LuaComparator( LuaThread thread, Object func, boolean desc ){
this.thread = thread;
this.comparator = func;
this.order = desc;
}
public int compare( Object A, Object B ) {
if ( A == null ) return 1;
if ( B == null ) return -1;
boolean isLess;
if ( comparator != null ){
isLess = LuaUtil.toBoolean( thread.call(comparator, A, B) );
} else {
| isLess = thread.compare(A, B, LuaOpcodes.OP_LT);
|
yescallop/EssentialsNK | src/main/java/cn/yescallop/essentialsnk/EssentialsNK.java | // Path: src/main/java/cn/yescallop/essentialsnk/command/CommandManager.java
// public class CommandManager {
//
// public static void registerAll(EssentialsAPI api) {
// CommandMap map = api.getServer().getCommandMap();
// map.register("EssentialsNK", new BackCommand(api));
// map.register("EssentialsNK", new BreakCommand(api));
// map.register("EssentialsNK", new BroadcastCommand(api));
// map.register("EssentialsNK", new BurnCommand(api));
// map.register("EssentialsNK", new ClearInventoryCommand(api));
// map.register("EssentialsNK", new CompassCommand(api));
// map.register("EssentialsNK", new DepthCommand(api));
// map.register("EssentialsNK", new ExtinguishCommand(api));
// map.register("EssentialsNK", new FeedCommand(api));
// map.register("EssentialsNK", new FlyCommand(api));
// map.register("EssentialsNK", new GamemodeCommand(api));
// map.register("EssentialsNK", new GetPosCommand(api));
// map.register("EssentialsNK", new HealCommand(api));
// map.register("EssentialsNK", new ItemDBCommand(api));
// map.register("EssentialsNK", new JumpCommand(api));
// map.register("EssentialsNK", new KickAllCommand(api));
// map.register("EssentialsNK", new LightningCommand(api));
// map.register("EssentialsNK", new MoreCommand(api));
// map.register("EssentialsNK", new MuteCommand(api));
// map.register("EssentialsNK", new PingCommand(api));
// map.register("EssentialsNK", new RealNameCommand(api));
// map.register("EssentialsNK", new RepairCommand(api));
// map.register("EssentialsNK", new SpeedCommand(api));
// map.register("EssentialsNK", new SudoCommand(api));
// map.register("EssentialsNK", new TopCommand(api));
// map.register("EssentialsNK", new VanishCommand(api));
// map.register("EssentialsNK", new WorldCommand(api));
//
// map.register("EssentialsNK", new DelHomeCommand(api));
// map.register("EssentialsNK", new HomeCommand(api));
// map.register("EssentialsNK", new SetHomeCommand(api));
//
// map.register("EssentialsNK", new TPACommand(api));
// map.register("EssentialsNK", new TPAAllCommand(api));
// map.register("EssentialsNK", new TPAcceptCommand(api));
// map.register("EssentialsNK", new TPAHereCommand(api));
// map.register("EssentialsNK", new TPAllCommand(api));
// map.register("EssentialsNK", new TPDenyCommand(api));
// map.register("EssentialsNK", new TPHereCommand(api));
//
// map.register("EssentialsNK", new DelWarpCommand(api));
// map.register("EssentialsNK", new WarpCommand(api));
// map.register("EssentialsNK", new SetWarpCommand(api));
//
// map.register("EssentialsNK", new SetSpawnCommand(api));
// map.register("EssentialsNK", new SpawnCommand(api));
// }
// }
| import cn.nukkit.plugin.PluginBase;
import cn.yescallop.essentialsnk.command.CommandManager; | package cn.yescallop.essentialsnk;
public class EssentialsNK extends PluginBase {
private EssentialsAPI api;
@Override
public void onEnable() {
this.getDataFolder().mkdirs();
Language.load(this.getServer().getLanguage().getLang());
this.api = new EssentialsAPI(this); | // Path: src/main/java/cn/yescallop/essentialsnk/command/CommandManager.java
// public class CommandManager {
//
// public static void registerAll(EssentialsAPI api) {
// CommandMap map = api.getServer().getCommandMap();
// map.register("EssentialsNK", new BackCommand(api));
// map.register("EssentialsNK", new BreakCommand(api));
// map.register("EssentialsNK", new BroadcastCommand(api));
// map.register("EssentialsNK", new BurnCommand(api));
// map.register("EssentialsNK", new ClearInventoryCommand(api));
// map.register("EssentialsNK", new CompassCommand(api));
// map.register("EssentialsNK", new DepthCommand(api));
// map.register("EssentialsNK", new ExtinguishCommand(api));
// map.register("EssentialsNK", new FeedCommand(api));
// map.register("EssentialsNK", new FlyCommand(api));
// map.register("EssentialsNK", new GamemodeCommand(api));
// map.register("EssentialsNK", new GetPosCommand(api));
// map.register("EssentialsNK", new HealCommand(api));
// map.register("EssentialsNK", new ItemDBCommand(api));
// map.register("EssentialsNK", new JumpCommand(api));
// map.register("EssentialsNK", new KickAllCommand(api));
// map.register("EssentialsNK", new LightningCommand(api));
// map.register("EssentialsNK", new MoreCommand(api));
// map.register("EssentialsNK", new MuteCommand(api));
// map.register("EssentialsNK", new PingCommand(api));
// map.register("EssentialsNK", new RealNameCommand(api));
// map.register("EssentialsNK", new RepairCommand(api));
// map.register("EssentialsNK", new SpeedCommand(api));
// map.register("EssentialsNK", new SudoCommand(api));
// map.register("EssentialsNK", new TopCommand(api));
// map.register("EssentialsNK", new VanishCommand(api));
// map.register("EssentialsNK", new WorldCommand(api));
//
// map.register("EssentialsNK", new DelHomeCommand(api));
// map.register("EssentialsNK", new HomeCommand(api));
// map.register("EssentialsNK", new SetHomeCommand(api));
//
// map.register("EssentialsNK", new TPACommand(api));
// map.register("EssentialsNK", new TPAAllCommand(api));
// map.register("EssentialsNK", new TPAcceptCommand(api));
// map.register("EssentialsNK", new TPAHereCommand(api));
// map.register("EssentialsNK", new TPAllCommand(api));
// map.register("EssentialsNK", new TPDenyCommand(api));
// map.register("EssentialsNK", new TPHereCommand(api));
//
// map.register("EssentialsNK", new DelWarpCommand(api));
// map.register("EssentialsNK", new WarpCommand(api));
// map.register("EssentialsNK", new SetWarpCommand(api));
//
// map.register("EssentialsNK", new SetSpawnCommand(api));
// map.register("EssentialsNK", new SpawnCommand(api));
// }
// }
// Path: src/main/java/cn/yescallop/essentialsnk/EssentialsNK.java
import cn.nukkit.plugin.PluginBase;
import cn.yescallop.essentialsnk.command.CommandManager;
package cn.yescallop.essentialsnk;
public class EssentialsNK extends PluginBase {
private EssentialsAPI api;
@Override
public void onEnable() {
this.getDataFolder().mkdirs();
Language.load(this.getServer().getLanguage().getLang());
this.api = new EssentialsAPI(this); | CommandManager.registerAll(this.api); |
ngs-doo/dsl-compiler-client | CommandLineClient/src/main/java/com/dslplatform/compiler/client/Context.java | // Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/parameters/LogOutput.java
// public enum LogOutput implements CompileParameter {
// INSTANCE;
//
// @Override
// public String getAlias() { return "log"; }
// @Override
// public String getUsage() { return null; }
//
// @Override
// public boolean check(final Context context) {
// return true;
// }
//
// @Override
// public void run(final Context context) {
// }
//
// @Override
// public String getShortDescription() {
// return "Show detailed log";
// }
//
// @Override
// public String getDetailedDescription() {
// return "Show exceptions with full stacktrace.\n" +
// "Show process output.\n" +
// "Show full DSL when added or removed.";
// }
// }
| import com.dslplatform.compiler.client.parameters.DisableColors;
import com.dslplatform.compiler.client.parameters.LogOutput;
import com.dslplatform.compiler.client.parameters.DisablePrompt;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Color;
import org.fusesource.jansi.AnsiConsole;
import java.io.*;
import java.util.HashMap;
import java.util.Map; | package com.dslplatform.compiler.client;
public class Context implements Closeable {
private final Map<String, String> parameters = new HashMap<String, String>();
private final Map<String, Object> cache = new HashMap<String, Object>();
private PrintStream console;
private boolean withLog;
private boolean noPrompt;
private boolean withColor = true;
public Context() {
this(AnsiConsole.out());
}
protected Context(PrintStream console) {
this.console = console;
}
public void put(final CompileParameter parameter, final String value) {
if (parameter instanceof DisablePrompt) {
noPrompt = true; | // Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/parameters/LogOutput.java
// public enum LogOutput implements CompileParameter {
// INSTANCE;
//
// @Override
// public String getAlias() { return "log"; }
// @Override
// public String getUsage() { return null; }
//
// @Override
// public boolean check(final Context context) {
// return true;
// }
//
// @Override
// public void run(final Context context) {
// }
//
// @Override
// public String getShortDescription() {
// return "Show detailed log";
// }
//
// @Override
// public String getDetailedDescription() {
// return "Show exceptions with full stacktrace.\n" +
// "Show process output.\n" +
// "Show full DSL when added or removed.";
// }
// }
// Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/Context.java
import com.dslplatform.compiler.client.parameters.DisableColors;
import com.dslplatform.compiler.client.parameters.LogOutput;
import com.dslplatform.compiler.client.parameters.DisablePrompt;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Color;
import org.fusesource.jansi.AnsiConsole;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
package com.dslplatform.compiler.client;
public class Context implements Closeable {
private final Map<String, String> parameters = new HashMap<String, String>();
private final Map<String, Object> cache = new HashMap<String, Object>();
private PrintStream console;
private boolean withLog;
private boolean noPrompt;
private boolean withColor = true;
public Context() {
this(AnsiConsole.out());
}
protected Context(PrintStream console) {
this.console = console;
}
public void put(final CompileParameter parameter, final String value) {
if (parameter instanceof DisablePrompt) {
noPrompt = true; | } else if (parameter instanceof LogOutput) { |
ngs-doo/dsl-compiler-client | CommandLineClient/src/main/java/com/dslplatform/compiler/client/parameters/LogOutput.java | // Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/Context.java
// public class Context implements Closeable {
// private final Map<String, String> parameters = new HashMap<String, String>();
// private final Map<String, Object> cache = new HashMap<String, Object>();
//
// private PrintStream console;
//
// private boolean withLog;
// private boolean noPrompt;
// private boolean withColor = true;
//
// public Context() {
// this(AnsiConsole.out());
// }
//
// protected Context(PrintStream console) {
// this.console = console;
// }
//
// public void put(final CompileParameter parameter, final String value) {
// if (parameter instanceof DisablePrompt) {
// noPrompt = true;
// } else if (parameter instanceof LogOutput) {
// withLog = true;
// } else if (parameter instanceof DisableColors) {
// withColor = false;
// console = System.out;
// }
// parameters.put(parameter.getAlias(), value);
// }
//
// public void put(final String parameter, final String value) {
// parameters.put(parameter.toLowerCase(), value);
// }
//
// public boolean contains(final CompileParameter parameter) {
// return parameters.containsKey(parameter.getAlias());
// }
//
// public boolean contains(final String parameter) {
// return parameters.containsKey(parameter);
// }
//
// public String get(final CompileParameter parameter) {
// return parameters.get(parameter.getAlias());
// }
//
// public String get(final String parameter) {
// return parameters.get(parameter.toLowerCase());
// }
//
// public void cache(final String name, final Object value) {
// cache.put(name, value);
// }
//
// public <T> T notify(final String action, final T target) {
// log("Notify: " + action + " for " + target);
// return target;
// }
//
// @SuppressWarnings("unchecked")
// public <T> T load(final String name) {
// return (T) cache.get(name);
// }
//
// private static synchronized void write(final PrintStream console, final boolean newLine, final String... values) {
// if (values.length == 0) {
// console.println();
// } else {
// if (newLine) {
// for (final String v : values) {
// console.println(v);
// }
// } else {
// for (final String v : values) {
// console.print(v);
// }
// }
// }
// console.flush();
// }
//
// public void show(final String... values) {
// write(console, true, values);
// }
//
// public static String inColor(final Ansi.Color color, final String message) {
// return Ansi.ansi().fg(color).a(message).reset().toString();
// }
//
// public void log(final String value) {
// if (withLog) {
// write(console, true, withColor ? inColor(Color.YELLOW, value) : value);
// }
// }
//
// public void log(final char[] value, final int len) {
// if (withLog) {
// final String msg = new String(value, 0, len);
// write(console, false, withColor ? inColor(Color.YELLOW, msg) : msg);
// }
// }
//
//
// public void warning(final String value) {
// write(console, true, withColor ? inColor(Color.MAGENTA, value) : value);
// }
//
// public void warning(final Exception ex) {
// warning(ex.getMessage());
// if (withLog) {
// final StringWriter sw = new StringWriter();
// ex.printStackTrace(new PrintWriter(sw));
// warning(sw.toString());
// }
// }
//
// public void error(final String value) {
// write(console, true, withColor ? inColor(Color.RED, value) : value);
// }
//
// public void error(final Exception ex) {
// if (ex instanceof ExitException) return;
// final String description = ex.getMessage();
// if (description == null) error(ex.getClass().getName() + " error without description");
// else error(description);
// if (withLog) {
// final StringWriter sw = new StringWriter();
// ex.printStackTrace(new PrintWriter(sw));
// error(sw.toString());
// }
// }
//
// public boolean canInteract() {
// return !noPrompt && System.console() != null;
// }
//
// private void askSafe(final String question, final Color color) {
// if (withColor) {
// try {
// write(console, false, Ansi.ansi().fgBright(color).bold().a(question + " ").boldOff().reset().toString());
// return;
// } catch (NoSuchMethodError ignore) {
// warning("Incompatible jansi found on classpath. Reverting to no-color");
// withColor = false;
// }
// }
// write(console, false, question + " ");
// }
//
// public String ask(final String question) {
// askSafe(question, Color.DEFAULT);
// return System.console().readLine();
// }
//
// public char[] askSecret(final String question) {
// askSafe(question, Color.CYAN);
// return System.console().readPassword();
// }
//
// @Override
// public void close() {
// for (Object it : cache.values()) {
// if (it instanceof Closeable) {
// try {
// ((Closeable) it).close();
// } catch (IOException e) {
// error(e);
// }
// }
// }
// }
// }
| import com.dslplatform.compiler.client.CompileParameter;
import com.dslplatform.compiler.client.Context; | package com.dslplatform.compiler.client.parameters;
public enum LogOutput implements CompileParameter {
INSTANCE;
@Override
public String getAlias() { return "log"; }
@Override
public String getUsage() { return null; }
@Override | // Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/Context.java
// public class Context implements Closeable {
// private final Map<String, String> parameters = new HashMap<String, String>();
// private final Map<String, Object> cache = new HashMap<String, Object>();
//
// private PrintStream console;
//
// private boolean withLog;
// private boolean noPrompt;
// private boolean withColor = true;
//
// public Context() {
// this(AnsiConsole.out());
// }
//
// protected Context(PrintStream console) {
// this.console = console;
// }
//
// public void put(final CompileParameter parameter, final String value) {
// if (parameter instanceof DisablePrompt) {
// noPrompt = true;
// } else if (parameter instanceof LogOutput) {
// withLog = true;
// } else if (parameter instanceof DisableColors) {
// withColor = false;
// console = System.out;
// }
// parameters.put(parameter.getAlias(), value);
// }
//
// public void put(final String parameter, final String value) {
// parameters.put(parameter.toLowerCase(), value);
// }
//
// public boolean contains(final CompileParameter parameter) {
// return parameters.containsKey(parameter.getAlias());
// }
//
// public boolean contains(final String parameter) {
// return parameters.containsKey(parameter);
// }
//
// public String get(final CompileParameter parameter) {
// return parameters.get(parameter.getAlias());
// }
//
// public String get(final String parameter) {
// return parameters.get(parameter.toLowerCase());
// }
//
// public void cache(final String name, final Object value) {
// cache.put(name, value);
// }
//
// public <T> T notify(final String action, final T target) {
// log("Notify: " + action + " for " + target);
// return target;
// }
//
// @SuppressWarnings("unchecked")
// public <T> T load(final String name) {
// return (T) cache.get(name);
// }
//
// private static synchronized void write(final PrintStream console, final boolean newLine, final String... values) {
// if (values.length == 0) {
// console.println();
// } else {
// if (newLine) {
// for (final String v : values) {
// console.println(v);
// }
// } else {
// for (final String v : values) {
// console.print(v);
// }
// }
// }
// console.flush();
// }
//
// public void show(final String... values) {
// write(console, true, values);
// }
//
// public static String inColor(final Ansi.Color color, final String message) {
// return Ansi.ansi().fg(color).a(message).reset().toString();
// }
//
// public void log(final String value) {
// if (withLog) {
// write(console, true, withColor ? inColor(Color.YELLOW, value) : value);
// }
// }
//
// public void log(final char[] value, final int len) {
// if (withLog) {
// final String msg = new String(value, 0, len);
// write(console, false, withColor ? inColor(Color.YELLOW, msg) : msg);
// }
// }
//
//
// public void warning(final String value) {
// write(console, true, withColor ? inColor(Color.MAGENTA, value) : value);
// }
//
// public void warning(final Exception ex) {
// warning(ex.getMessage());
// if (withLog) {
// final StringWriter sw = new StringWriter();
// ex.printStackTrace(new PrintWriter(sw));
// warning(sw.toString());
// }
// }
//
// public void error(final String value) {
// write(console, true, withColor ? inColor(Color.RED, value) : value);
// }
//
// public void error(final Exception ex) {
// if (ex instanceof ExitException) return;
// final String description = ex.getMessage();
// if (description == null) error(ex.getClass().getName() + " error without description");
// else error(description);
// if (withLog) {
// final StringWriter sw = new StringWriter();
// ex.printStackTrace(new PrintWriter(sw));
// error(sw.toString());
// }
// }
//
// public boolean canInteract() {
// return !noPrompt && System.console() != null;
// }
//
// private void askSafe(final String question, final Color color) {
// if (withColor) {
// try {
// write(console, false, Ansi.ansi().fgBright(color).bold().a(question + " ").boldOff().reset().toString());
// return;
// } catch (NoSuchMethodError ignore) {
// warning("Incompatible jansi found on classpath. Reverting to no-color");
// withColor = false;
// }
// }
// write(console, false, question + " ");
// }
//
// public String ask(final String question) {
// askSafe(question, Color.DEFAULT);
// return System.console().readLine();
// }
//
// public char[] askSecret(final String question) {
// askSafe(question, Color.CYAN);
// return System.console().readPassword();
// }
//
// @Override
// public void close() {
// for (Object it : cache.values()) {
// if (it instanceof Closeable) {
// try {
// ((Closeable) it).close();
// } catch (IOException e) {
// error(e);
// }
// }
// }
// }
// }
// Path: CommandLineClient/src/main/java/com/dslplatform/compiler/client/parameters/LogOutput.java
import com.dslplatform.compiler.client.CompileParameter;
import com.dslplatform.compiler.client.Context;
package com.dslplatform.compiler.client.parameters;
public enum LogOutput implements CompileParameter {
INSTANCE;
@Override
public String getAlias() { return "log"; }
@Override
public String getUsage() { return null; }
@Override | public boolean check(final Context context) { |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/Profile1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java
// @SuppressWarnings("serial")
// public class BluezCanceledException extends DBusException {
//
// public BluezCanceledException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java
// @SuppressWarnings("serial")
// public class BluezRejectedException extends DBusException {
//
// public BluezRejectedException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.exceptions.BluezCanceledException;
import org.bluez.exceptions.BluezRejectedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: profile-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.Profile1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
*/
public interface Profile1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when the service daemon<br>
* unregisters the profile. A profile can use it to do<br>
* cleanup tasks. There is no need to unregister the<br>
* profile, because when this method gets called it has<br>
* already been unregistered.<br>
* <br>
*/
void Release();
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when a new service level<br>
* connection has been made and authorized.<br>
* <br>
* Common fd_properties:<br>
* <br>
* uint16 Version Profile version (optional)<br>
* uint16 Features Profile features (optional)<br>
* <br>
*
* @param _device device
* @param fd fd
* @param _fd_properties fd_properties
*
* @throws BluezRejectedException when operation rejected
* @throws BluezCanceledException when operation canceled
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java
// @SuppressWarnings("serial")
// public class BluezCanceledException extends DBusException {
//
// public BluezCanceledException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java
// @SuppressWarnings("serial")
// public class BluezRejectedException extends DBusException {
//
// public BluezRejectedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java
import java.util.Map;
import org.bluez.exceptions.BluezCanceledException;
import org.bluez.exceptions.BluezRejectedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: profile-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.Profile1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
*/
public interface Profile1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when the service daemon<br>
* unregisters the profile. A profile can use it to do<br>
* cleanup tasks. There is no need to unregister the<br>
* profile, because when this method gets called it has<br>
* already been unregistered.<br>
* <br>
*/
void Release();
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when a new service level<br>
* connection has been made and authorized.<br>
* <br>
* Common fd_properties:<br>
* <br>
* uint16 Version Profile version (optional)<br>
* uint16 Features Profile features (optional)<br>
* <br>
*
* @param _device device
* @param fd fd
* @param _fd_properties fd_properties
*
* @throws BluezRejectedException when operation rejected
* @throws BluezCanceledException when operation canceled
*/ | void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/Profile1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java
// @SuppressWarnings("serial")
// public class BluezCanceledException extends DBusException {
//
// public BluezCanceledException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java
// @SuppressWarnings("serial")
// public class BluezRejectedException extends DBusException {
//
// public BluezRejectedException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.exceptions.BluezCanceledException;
import org.bluez.exceptions.BluezRejectedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: profile-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.Profile1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
*/
public interface Profile1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when the service daemon<br>
* unregisters the profile. A profile can use it to do<br>
* cleanup tasks. There is no need to unregister the<br>
* profile, because when this method gets called it has<br>
* already been unregistered.<br>
* <br>
*/
void Release();
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when a new service level<br>
* connection has been made and authorized.<br>
* <br>
* Common fd_properties:<br>
* <br>
* uint16 Version Profile version (optional)<br>
* uint16 Features Profile features (optional)<br>
* <br>
*
* @param _device device
* @param fd fd
* @param _fd_properties fd_properties
*
* @throws BluezRejectedException when operation rejected
* @throws BluezCanceledException when operation canceled
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezCanceledException.java
// @SuppressWarnings("serial")
// public class BluezCanceledException extends DBusException {
//
// public BluezCanceledException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezRejectedException.java
// @SuppressWarnings("serial")
// public class BluezRejectedException extends DBusException {
//
// public BluezRejectedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/Profile1.java
import java.util.Map;
import org.bluez.exceptions.BluezCanceledException;
import org.bluez.exceptions.BluezRejectedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: profile-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.Profile1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
*/
public interface Profile1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when the service daemon<br>
* unregisters the profile. A profile can use it to do<br>
* cleanup tasks. There is no need to unregister the<br>
* profile, because when this method gets called it has<br>
* already been unregistered.<br>
* <br>
*/
void Release();
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method gets called when a new service level<br>
* connection has been made and authorized.<br>
* <br>
* Common fd_properties:<br>
* <br>
* uint16 Version Profile version (optional)<br>
* uint16 Features Profile features (optional)<br>
* <br>
*
* @param _device device
* @param fd fd
* @param _fd_properties fd_properties
*
* @throws BluezRejectedException when operation rejected
* @throws BluezCanceledException when operation canceled
*/ | void NewConnection(DBusPath _device, FileDescriptor fd, Map<String, Variant<?>> _fd_properties) throws BluezRejectedException, BluezCanceledException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/LEAdvertisingManager1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java
// @SuppressWarnings("serial")
// public class BluezAlreadyExistsException extends DBusException {
//
// public BluezAlreadyExistsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java
// @SuppressWarnings("serial")
// public class BluezDoesNotExistException extends DBusException {
//
// public BluezDoesNotExistException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidLengthException.java
// @SuppressWarnings("serial")
// public class BluezInvalidLengthException extends DBusException {
//
// public BluezInvalidLengthException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotPermittedException.java
// @SuppressWarnings("serial")
// public class BluezNotPermittedException extends DBusException {
//
// public BluezNotPermittedException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.exceptions.BluezAlreadyExistsException;
import org.bluez.exceptions.BluezDoesNotExistException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezInvalidLengthException;
import org.bluez.exceptions.BluezNotPermittedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: advertising-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.LEAdvertisingManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/{hci0,hci1,...}<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* byte ActiveInstances<br>
* <br>
* Number of active advertising instances.<br>
* <br>
* byte SupportedInstances<br>
* <br>
* Number of available advertising instances.<br>
* <br>
* array{string} SupportedIncludes<br>
* <br>
* List of supported system includes.<br>
* <br>
* Possible values: "tx-power"<br>
* "appearance"<br>
* "local-name"<br>
* <br>
* array{string} SupportedSecondaryChannels [Experimental]<br>
* <br>
* List of supported Secondary channels. Secondary<br>
* channels can be used to advertise with the<br>
* corresponding PHY.<br>
* <br>
* Possible values: "1M"<br>
* "2M"<br>
* "Coded"<br>
* <br>
*/
public interface LEAdvertisingManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Registers an advertisement object to be sent over the LE<br>
* Advertising channel. The service must be exported<br>
* under interface LEAdvertisement1.<br>
* <br>
* InvalidArguments error indicates that the object has<br>
* invalid or conflicting properties.<br>
* <br>
* InvalidLength error indicates that the data<br>
* provided generates a data packet which is too long.<br>
* <br>
* The properties of this object are parsed when it is<br>
* registered, and any changes are ignored.<br>
* <br>
* If the same object is registered twice it will result in<br>
* an AlreadyExists error.<br>
* <br>
* If the maximum number of advertisement instances is<br>
* reached it will result in NotPermitted error.<br>
* <br>
*
* @param _advertisement advertisement
* @param _options options
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezAlreadyExistsException when item already exists
* @throws BluezInvalidLengthException on BluezInvalidLengthException
* @throws BluezNotPermittedException on BluezNotPermittedException
*/
void RegisterAdvertisement(DBusPath _advertisement, Map<String, Variant<?>> _options) throws BluezInvalidArgumentsException, BluezAlreadyExistsException, BluezInvalidLengthException, BluezNotPermittedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* This unregisters an advertisement that has been<br>
* previously registered. The object path parameter must<br>
* match the same value that has been used on registration.<br>
* <br>
*
* @param _advertisement advertisement
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezDoesNotExistException when item does not exist
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyExistsException.java
// @SuppressWarnings("serial")
// public class BluezAlreadyExistsException extends DBusException {
//
// public BluezAlreadyExistsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezDoesNotExistException.java
// @SuppressWarnings("serial")
// public class BluezDoesNotExistException extends DBusException {
//
// public BluezDoesNotExistException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidLengthException.java
// @SuppressWarnings("serial")
// public class BluezInvalidLengthException extends DBusException {
//
// public BluezInvalidLengthException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotPermittedException.java
// @SuppressWarnings("serial")
// public class BluezNotPermittedException extends DBusException {
//
// public BluezNotPermittedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/LEAdvertisingManager1.java
import java.util.Map;
import org.bluez.exceptions.BluezAlreadyExistsException;
import org.bluez.exceptions.BluezDoesNotExistException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezInvalidLengthException;
import org.bluez.exceptions.BluezNotPermittedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: advertising-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.LEAdvertisingManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/{hci0,hci1,...}<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* byte ActiveInstances<br>
* <br>
* Number of active advertising instances.<br>
* <br>
* byte SupportedInstances<br>
* <br>
* Number of available advertising instances.<br>
* <br>
* array{string} SupportedIncludes<br>
* <br>
* List of supported system includes.<br>
* <br>
* Possible values: "tx-power"<br>
* "appearance"<br>
* "local-name"<br>
* <br>
* array{string} SupportedSecondaryChannels [Experimental]<br>
* <br>
* List of supported Secondary channels. Secondary<br>
* channels can be used to advertise with the<br>
* corresponding PHY.<br>
* <br>
* Possible values: "1M"<br>
* "2M"<br>
* "Coded"<br>
* <br>
*/
public interface LEAdvertisingManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Registers an advertisement object to be sent over the LE<br>
* Advertising channel. The service must be exported<br>
* under interface LEAdvertisement1.<br>
* <br>
* InvalidArguments error indicates that the object has<br>
* invalid or conflicting properties.<br>
* <br>
* InvalidLength error indicates that the data<br>
* provided generates a data packet which is too long.<br>
* <br>
* The properties of this object are parsed when it is<br>
* registered, and any changes are ignored.<br>
* <br>
* If the same object is registered twice it will result in<br>
* an AlreadyExists error.<br>
* <br>
* If the maximum number of advertisement instances is<br>
* reached it will result in NotPermitted error.<br>
* <br>
*
* @param _advertisement advertisement
* @param _options options
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezAlreadyExistsException when item already exists
* @throws BluezInvalidLengthException on BluezInvalidLengthException
* @throws BluezNotPermittedException on BluezNotPermittedException
*/
void RegisterAdvertisement(DBusPath _advertisement, Map<String, Variant<?>> _options) throws BluezInvalidArgumentsException, BluezAlreadyExistsException, BluezInvalidLengthException, BluezNotPermittedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* This unregisters an advertisement that has been<br>
* previously registered. The object path parameter must<br>
* match the same value that has been used on registration.<br>
* <br>
*
* @param _advertisement advertisement
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezDoesNotExistException when item does not exist
*/ | void UnregisterAdvertisement(DBusPath _advertisement) throws BluezInvalidArgumentsException, BluezDoesNotExistException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/HealthManager1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java
// @SuppressWarnings("serial")
// public class BluezNotAllowedException extends DBusException {
//
// public BluezNotAllowedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotAllowedException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: health-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.HealthManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/<br>
* <br>
*/
public interface HealthManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Returns the path of the new registered application.<br>
* Application will be closed by the call or implicitly<br>
* when the programs leaves the bus.<br>
* <br>
* config:<br>
* uint16 DataType:<br>
* <br>
* Mandatory<br>
* <br>
* string Role:<br>
* <br>
* Mandatory. Possible values: "source",<br>
* "sink"<br>
* <br>
* string Description:<br>
* <br>
* Optional<br>
* <br>
* ChannelType:<br>
* <br>
* Optional, just for sources. Possible<br>
* values: "reliable", "streaming"<br>
* <br>
*
* @param _config config
*
* @return DBusPath - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
DBusPath CreateApplication(Map<String, Variant<?>> _config) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Closes the HDP application identified by the object<br>
* path. Also application will be closed if the process<br>
* that started it leaves the bus. Only the creator of the<br>
* application will be able to destroy it.<br>
* <br>
*
* @param _application application
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
* @throws BluezNotAllowedException when operation not allowed
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java
// @SuppressWarnings("serial")
// public class BluezNotAllowedException extends DBusException {
//
// public BluezNotAllowedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/HealthManager1.java
import java.util.Map;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotAllowedException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: health-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.HealthManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/<br>
* <br>
*/
public interface HealthManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Returns the path of the new registered application.<br>
* Application will be closed by the call or implicitly<br>
* when the programs leaves the bus.<br>
* <br>
* config:<br>
* uint16 DataType:<br>
* <br>
* Mandatory<br>
* <br>
* string Role:<br>
* <br>
* Mandatory. Possible values: "source",<br>
* "sink"<br>
* <br>
* string Description:<br>
* <br>
* Optional<br>
* <br>
* ChannelType:<br>
* <br>
* Optional, just for sources. Possible<br>
* values: "reliable", "streaming"<br>
* <br>
*
* @param _config config
*
* @return DBusPath - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
DBusPath CreateApplication(Map<String, Variant<?>> _config) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Closes the HDP application identified by the object<br>
* path. Also application will be closed if the process<br>
* that started it leaves the bus. Only the creator of the<br>
* application will be able to destroy it.<br>
* <br>
*
* @param _application application
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
* @throws BluezNotAllowedException when operation not allowed
*/ | void DestroyApplication(DBusPath _application) throws BluezInvalidArgumentsException, BluezNotFoundException, BluezNotAllowedException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/HealthManager1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java
// @SuppressWarnings("serial")
// public class BluezNotAllowedException extends DBusException {
//
// public BluezNotAllowedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotAllowedException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: health-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.HealthManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/<br>
* <br>
*/
public interface HealthManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Returns the path of the new registered application.<br>
* Application will be closed by the call or implicitly<br>
* when the programs leaves the bus.<br>
* <br>
* config:<br>
* uint16 DataType:<br>
* <br>
* Mandatory<br>
* <br>
* string Role:<br>
* <br>
* Mandatory. Possible values: "source",<br>
* "sink"<br>
* <br>
* string Description:<br>
* <br>
* Optional<br>
* <br>
* ChannelType:<br>
* <br>
* Optional, just for sources. Possible<br>
* values: "reliable", "streaming"<br>
* <br>
*
* @param _config config
*
* @return DBusPath - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
DBusPath CreateApplication(Map<String, Variant<?>> _config) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Closes the HDP application identified by the object<br>
* path. Also application will be closed if the process<br>
* that started it leaves the bus. Only the creator of the<br>
* application will be able to destroy it.<br>
* <br>
*
* @param _application application
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
* @throws BluezNotAllowedException when operation not allowed
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAllowedException.java
// @SuppressWarnings("serial")
// public class BluezNotAllowedException extends DBusException {
//
// public BluezNotAllowedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/HealthManager1.java
import java.util.Map;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotAllowedException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: health-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.HealthManager1<br>
* <br>
* <b>Object path:</b><br>
* /org/bluez/<br>
* <br>
*/
public interface HealthManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Returns the path of the new registered application.<br>
* Application will be closed by the call or implicitly<br>
* when the programs leaves the bus.<br>
* <br>
* config:<br>
* uint16 DataType:<br>
* <br>
* Mandatory<br>
* <br>
* string Role:<br>
* <br>
* Mandatory. Possible values: "source",<br>
* "sink"<br>
* <br>
* string Description:<br>
* <br>
* Optional<br>
* <br>
* ChannelType:<br>
* <br>
* Optional, just for sources. Possible<br>
* values: "reliable", "streaming"<br>
* <br>
*
* @param _config config
*
* @return DBusPath - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
DBusPath CreateApplication(Map<String, Variant<?>> _config) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Closes the HDP application identified by the object<br>
* path. Also application will be closed if the process<br>
* that started it leaves the bus. Only the creator of the<br>
* application will be able to destroy it.<br>
* <br>
*
* @param _application application
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
* @throws BluezNotAllowedException when operation not allowed
*/ | void DestroyApplication(DBusPath _application) throws BluezInvalidArgumentsException, BluezNotFoundException, BluezNotAllowedException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/ThermometerManager1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
| import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: thermometer-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.ThermometerManager1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}<br>
* <br>
*/
public interface ThermometerManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Registers a watcher to monitor scanned measurements.<br>
* This agent will be notified about final temperature<br>
* measurements.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
void RegisterWatcher(DBusPath _agent) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Unregisters a watcher.<br>
* <br>
*
* @param _agent agent
*/
void UnregisterWatcher(DBusPath _agent);
/**
* <b>From bluez documentation:</b><br>
* <br>
* Enables intermediate measurement notifications<br>
* for this agent. Intermediate measurements will<br>
* be enabled only for thermometers which support it.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
void EnableIntermediateMeasurement(DBusPath _agent) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Disables intermediate measurement notifications<br>
* for this agent. It will disable notifications in<br>
* thermometers when the last agent removes the<br>
* watcher for intermediate measurements.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotFoundException.java
// @SuppressWarnings("serial")
// public class BluezNotFoundException extends DBusException {
//
// public BluezNotFoundException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/ThermometerManager1.java
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotFoundException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: thermometer-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.ThermometerManager1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}<br>
* <br>
*/
public interface ThermometerManager1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Registers a watcher to monitor scanned measurements.<br>
* This agent will be notified about final temperature<br>
* measurements.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
void RegisterWatcher(DBusPath _agent) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Unregisters a watcher.<br>
* <br>
*
* @param _agent agent
*/
void UnregisterWatcher(DBusPath _agent);
/**
* <b>From bluez documentation:</b><br>
* <br>
* Enables intermediate measurement notifications<br>
* for this agent. Intermediate measurements will<br>
* be enabled only for thermometers which support it.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
*/
void EnableIntermediateMeasurement(DBusPath _agent) throws BluezInvalidArgumentsException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Disables intermediate measurement notifications<br>
* for this agent. It will disable notifications in<br>
* thermometers when the last agent removes the<br>
* watcher for intermediate measurements.<br>
* <br>
*
* @param _agent agent
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotFoundException when item not found
*/ | void DisableIntermediateMeasurement(DBusPath _agent) throws BluezInvalidArgumentsException, BluezNotFoundException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/obex/Transfer1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInProgressException.java
// @SuppressWarnings("serial")
// public class BluezInProgressException extends DBusException {
//
// public BluezInProgressException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java
// @SuppressWarnings("serial")
// public class BluezNotAuthorizedException extends DBusException {
//
// public BluezNotAuthorizedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotInProgressException.java
// @SuppressWarnings("serial")
// public class BluezNotInProgressException extends DBusException {
//
// public BluezNotInProgressException(String _message) {
// super(_message);
// }
//
// }
| import org.freedesktop.dbus.interfaces.DBusInterface;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInProgressException;
import org.bluez.exceptions.BluezNotAuthorizedException;
import org.bluez.exceptions.BluezNotInProgressException; | package org.bluez.obex;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: obex-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez.obex<br>
* <b>Interface:</b> org.bluez.obex.Transfer1<br>
* <br>
* <b>Object path:</b><br>
* [Session object path]/transfer{0, 1, 2, ...}<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* string Status [readonly]<br>
* <br>
* Inform the current status of the transfer.<br>
* <br>
* Possible values: "queued", "active", "suspended",<br>
* "complete" or "error"<br>
* <br>
* object Session [readonly]<br>
* <br>
* The object path of the session the transfer belongs<br>
* to.<br>
* <br>
* string Name [readonly]<br>
* <br>
* Name of the transferred object. Either Name or Type<br>
* or both will be present.<br>
* <br>
* string Type [readonly]<br>
* <br>
* Type of the transferred object. Either Name or Type<br>
* or both will be present.<br>
* <br>
* uint64 Time [readonly, optional]<br>
* <br>
* Time of the transferred object if this is<br>
* provided by the remote party.<br>
* <br>
* uint64 Size [readonly, optional]<br>
* <br>
* Size of the transferred object. If the size is<br>
* unknown, then this property will not be present.<br>
* <br>
* uint64 Transferred [readonly, optional]<br>
* <br>
* Number of bytes transferred. For queued transfers, this<br>
* value will not be present.<br>
* <br>
* string Filename [readonly, optional]<br>
* <br>
* Complete name of the file being received or sent.<br>
* <br>
* For incoming object push transaction, this will be<br>
* the proposed default location and name. It can be<br>
* overwritten by the AuthorizePush agent callback<br>
* and will be then updated accordingly.<br>
* <br>
* <br>
* <br>
*/
public interface Transfer1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Stops the current transference.<br>
* <br>
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezInProgressException when operation already in progress
* @throws BluezFailedException on failure
*/
void Cancel() throws BluezNotAuthorizedException, BluezInProgressException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Suspend transference.<br>
* <br>
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezNotInProgressException on BluezNotInProgressException
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInProgressException.java
// @SuppressWarnings("serial")
// public class BluezInProgressException extends DBusException {
//
// public BluezInProgressException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java
// @SuppressWarnings("serial")
// public class BluezNotAuthorizedException extends DBusException {
//
// public BluezNotAuthorizedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotInProgressException.java
// @SuppressWarnings("serial")
// public class BluezNotInProgressException extends DBusException {
//
// public BluezNotInProgressException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/obex/Transfer1.java
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInProgressException;
import org.bluez.exceptions.BluezNotAuthorizedException;
import org.bluez.exceptions.BluezNotInProgressException;
package org.bluez.obex;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: obex-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez.obex<br>
* <b>Interface:</b> org.bluez.obex.Transfer1<br>
* <br>
* <b>Object path:</b><br>
* [Session object path]/transfer{0, 1, 2, ...}<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* string Status [readonly]<br>
* <br>
* Inform the current status of the transfer.<br>
* <br>
* Possible values: "queued", "active", "suspended",<br>
* "complete" or "error"<br>
* <br>
* object Session [readonly]<br>
* <br>
* The object path of the session the transfer belongs<br>
* to.<br>
* <br>
* string Name [readonly]<br>
* <br>
* Name of the transferred object. Either Name or Type<br>
* or both will be present.<br>
* <br>
* string Type [readonly]<br>
* <br>
* Type of the transferred object. Either Name or Type<br>
* or both will be present.<br>
* <br>
* uint64 Time [readonly, optional]<br>
* <br>
* Time of the transferred object if this is<br>
* provided by the remote party.<br>
* <br>
* uint64 Size [readonly, optional]<br>
* <br>
* Size of the transferred object. If the size is<br>
* unknown, then this property will not be present.<br>
* <br>
* uint64 Transferred [readonly, optional]<br>
* <br>
* Number of bytes transferred. For queued transfers, this<br>
* value will not be present.<br>
* <br>
* string Filename [readonly, optional]<br>
* <br>
* Complete name of the file being received or sent.<br>
* <br>
* For incoming object push transaction, this will be<br>
* the proposed default location and name. It can be<br>
* overwritten by the AuthorizePush agent callback<br>
* and will be then updated accordingly.<br>
* <br>
* <br>
* <br>
*/
public interface Transfer1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Stops the current transference.<br>
* <br>
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezInProgressException when operation already in progress
* @throws BluezFailedException on failure
*/
void Cancel() throws BluezNotAuthorizedException, BluezInProgressException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Suspend transference.<br>
* <br>
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezNotInProgressException on BluezNotInProgressException
*/ | void Suspend() throws BluezNotAuthorizedException, BluezNotInProgressException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/Network1.java | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyConnectedException.java
// @SuppressWarnings("serial")
// public class BluezAlreadyConnectedException extends DBusException {
//
// public BluezAlreadyConnectedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezConnectionAttemptFailedException.java
// @SuppressWarnings("serial")
// public class BluezConnectionAttemptFailedException extends DBusException {
//
// public BluezConnectionAttemptFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
| import org.bluez.exceptions.BluezAlreadyConnectedException;
import org.bluez.exceptions.BluezConnectionAttemptFailedException;
import org.bluez.exceptions.BluezFailedException;
import org.freedesktop.dbus.interfaces.DBusInterface; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: network-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.Network1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* boolean Connected [readonly]<br>
* <br>
* Indicates if the device is connected.<br>
* <br>
* string Interface [readonly]<br>
* <br>
* Indicates the network interface name when available.<br>
* <br>
* string UUID [readonly]<br>
* <br>
* Indicates the connection role when available.<br>
* <br>
* <br>
* <br>
*/
public interface Network1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Connect to the network device and return the network<br>
* interface name. Examples of the interface name are<br>
* bnep0, bnep1 etc.<br>
* <br>
* uuid can be either one of "gn", "panu" or "nap" (case<br>
* insensitive) or a traditional string representation of<br>
* UUID or a hexadecimal number.<br>
* <br>
* The connection will be closed and network device<br>
* released either upon calling Disconnect() or when<br>
* the client disappears from the message bus.<br>
* <br>
*
* @param _uuid uuid
*
* @return String - maybe null
*
* @throws BluezAlreadyConnectedException when already connected
* @throws BluezConnectionAttemptFailedException when connection attempt failed
*/
String Connect(String _uuid) throws BluezAlreadyConnectedException, BluezConnectionAttemptFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Disconnect from the network device.<br>
* <br>
* To abort a connection attempt in case of errors or<br>
* timeouts in the client it is fine to call this method.<br>
* <br>
*
* @throws BluezFailedException on failure
*/ | // Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezAlreadyConnectedException.java
// @SuppressWarnings("serial")
// public class BluezAlreadyConnectedException extends DBusException {
//
// public BluezAlreadyConnectedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezConnectionAttemptFailedException.java
// @SuppressWarnings("serial")
// public class BluezConnectionAttemptFailedException extends DBusException {
//
// public BluezConnectionAttemptFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/Network1.java
import org.bluez.exceptions.BluezAlreadyConnectedException;
import org.bluez.exceptions.BluezConnectionAttemptFailedException;
import org.bluez.exceptions.BluezFailedException;
import org.freedesktop.dbus.interfaces.DBusInterface;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: network-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.Network1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* boolean Connected [readonly]<br>
* <br>
* Indicates if the device is connected.<br>
* <br>
* string Interface [readonly]<br>
* <br>
* Indicates the network interface name when available.<br>
* <br>
* string UUID [readonly]<br>
* <br>
* Indicates the connection role when available.<br>
* <br>
* <br>
* <br>
*/
public interface Network1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Connect to the network device and return the network<br>
* interface name. Examples of the interface name are<br>
* bnep0, bnep1 etc.<br>
* <br>
* uuid can be either one of "gn", "panu" or "nap" (case<br>
* insensitive) or a traditional string representation of<br>
* UUID or a hexadecimal number.<br>
* <br>
* The connection will be closed and network device<br>
* released either upon calling Disconnect() or when<br>
* the client disappears from the message bus.<br>
* <br>
*
* @param _uuid uuid
*
* @return String - maybe null
*
* @throws BluezAlreadyConnectedException when already connected
* @throws BluezConnectionAttemptFailedException when connection attempt failed
*/
String Connect(String _uuid) throws BluezAlreadyConnectedException, BluezConnectionAttemptFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Disconnect from the network device.<br>
* <br>
* To abort a connection attempt in case of errors or<br>
* timeouts in the client it is fine to call this method.<br>
* <br>
*
* @throws BluezFailedException on failure
*/ | void Disconnect() throws BluezFailedException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/MediaFolder1.java | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java
// @SuppressWarnings("serial")
// public class BluezNotSupportedException extends DBusException {
//
// public BluezNotSupportedException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import java.util.Properties;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotSupportedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> unique name (Target role)<br>
* <b>Interface:</b> org.bluez.MediaFolder1<br>
* <br>
* <b>Object path:</b><br>
* freely definable (Target role)<br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX<br>
* (Controller role)
* <br>
* <b>Supported properties:</b> <br>
* <br>
* uint32 NumberOfItems [readonly]<br>
* <br>
* Number of items in the folder<br>
* <br>
* string Name [readonly]<br>
* <br>
* Folder name:<br>
* <br>
* Possible values:<br>
* "/Filesystem/...": Filesystem scope<br>
* "/NowPlaying/...": NowPlaying scope<br>
* <br>
* Note: /NowPlaying folder might not be listed if player<br>
* is stopped, folders created by Search are virtual so<br>
* once another Search is perform or the folder is<br>
* changed using ChangeFolder it will no longer be listed.<br>
* <br>
* <br>
* Offset of the first item.<br>
* <br>
* Default value: 0<br>
* <br>
* uint32 End:<br>
* <br>
* Offset of the last item.<br>
* <br>
* Default value: NumbeOfItems<br>
* <br>
* array{string} Attributes<br>
* <br>
* Item properties that should be included in the list.<br>
* <br>
* Possible Values:<br>
* <br>
* "title", "artist", "album", "genre",<br>
* "number-of-tracks", "number", "duration"<br>
* <br>
* Default Value: All<br>
* <br>
* <br>
*/
public interface MediaFolder1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a folder object containing the search result.<br>
* <br>
* To list the items found use the folder object returned<br>
* and pass to ChangeFolder.<br>
* <br>
*
* @param _value value
* @param _filter filter
*
* @return DBusPath - maybe null
*
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/
DBusPath Search(String _value, Map<String, Variant<?>> _filter) throws BluezNotSupportedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a list of items found<br>
* <br>
*
* @param _filter filter
*
* @return TwoTuple<DBusPath, Properties>[] - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/ | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java
// @SuppressWarnings("serial")
// public class BluezNotSupportedException extends DBusException {
//
// public BluezNotSupportedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/MediaFolder1.java
import java.util.Map;
import java.util.Properties;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotSupportedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> unique name (Target role)<br>
* <b>Interface:</b> org.bluez.MediaFolder1<br>
* <br>
* <b>Object path:</b><br>
* freely definable (Target role)<br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX<br>
* (Controller role)
* <br>
* <b>Supported properties:</b> <br>
* <br>
* uint32 NumberOfItems [readonly]<br>
* <br>
* Number of items in the folder<br>
* <br>
* string Name [readonly]<br>
* <br>
* Folder name:<br>
* <br>
* Possible values:<br>
* "/Filesystem/...": Filesystem scope<br>
* "/NowPlaying/...": NowPlaying scope<br>
* <br>
* Note: /NowPlaying folder might not be listed if player<br>
* is stopped, folders created by Search are virtual so<br>
* once another Search is perform or the folder is<br>
* changed using ChangeFolder it will no longer be listed.<br>
* <br>
* <br>
* Offset of the first item.<br>
* <br>
* Default value: 0<br>
* <br>
* uint32 End:<br>
* <br>
* Offset of the last item.<br>
* <br>
* Default value: NumbeOfItems<br>
* <br>
* array{string} Attributes<br>
* <br>
* Item properties that should be included in the list.<br>
* <br>
* Possible Values:<br>
* <br>
* "title", "artist", "album", "genre",<br>
* "number-of-tracks", "number", "duration"<br>
* <br>
* Default Value: All<br>
* <br>
* <br>
*/
public interface MediaFolder1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a folder object containing the search result.<br>
* <br>
* To list the items found use the folder object returned<br>
* and pass to ChangeFolder.<br>
* <br>
*
* @param _value value
* @param _filter filter
*
* @return DBusPath - maybe null
*
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/
DBusPath Search(String _value, Map<String, Variant<?>> _filter) throws BluezNotSupportedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a list of items found<br>
* <br>
*
* @param _filter filter
*
* @return TwoTuple<DBusPath, Properties>[] - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/ | TwoTuple<DBusPath, Properties>[] ListItems(Map<String, Variant<?>> _filter) throws BluezInvalidArgumentsException, BluezNotSupportedException, BluezFailedException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/MediaFolder1.java | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java
// @SuppressWarnings("serial")
// public class BluezNotSupportedException extends DBusException {
//
// public BluezNotSupportedException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import java.util.Properties;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotSupportedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> unique name (Target role)<br>
* <b>Interface:</b> org.bluez.MediaFolder1<br>
* <br>
* <b>Object path:</b><br>
* freely definable (Target role)<br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX<br>
* (Controller role)
* <br>
* <b>Supported properties:</b> <br>
* <br>
* uint32 NumberOfItems [readonly]<br>
* <br>
* Number of items in the folder<br>
* <br>
* string Name [readonly]<br>
* <br>
* Folder name:<br>
* <br>
* Possible values:<br>
* "/Filesystem/...": Filesystem scope<br>
* "/NowPlaying/...": NowPlaying scope<br>
* <br>
* Note: /NowPlaying folder might not be listed if player<br>
* is stopped, folders created by Search are virtual so<br>
* once another Search is perform or the folder is<br>
* changed using ChangeFolder it will no longer be listed.<br>
* <br>
* <br>
* Offset of the first item.<br>
* <br>
* Default value: 0<br>
* <br>
* uint32 End:<br>
* <br>
* Offset of the last item.<br>
* <br>
* Default value: NumbeOfItems<br>
* <br>
* array{string} Attributes<br>
* <br>
* Item properties that should be included in the list.<br>
* <br>
* Possible Values:<br>
* <br>
* "title", "artist", "album", "genre",<br>
* "number-of-tracks", "number", "duration"<br>
* <br>
* Default Value: All<br>
* <br>
* <br>
*/
public interface MediaFolder1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a folder object containing the search result.<br>
* <br>
* To list the items found use the folder object returned<br>
* and pass to ChangeFolder.<br>
* <br>
*
* @param _value value
* @param _filter filter
*
* @return DBusPath - maybe null
*
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/
DBusPath Search(String _value, Map<String, Variant<?>> _filter) throws BluezNotSupportedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a list of items found<br>
* <br>
*
* @param _filter filter
*
* @return TwoTuple<DBusPath, Properties>[] - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/ | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezInvalidArgumentsException.java
// @SuppressWarnings("serial")
// public class BluezInvalidArgumentsException extends DBusException {
//
// public BluezInvalidArgumentsException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotSupportedException.java
// @SuppressWarnings("serial")
// public class BluezNotSupportedException extends DBusException {
//
// public BluezNotSupportedException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/MediaFolder1.java
import java.util.Map;
import java.util.Properties;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezInvalidArgumentsException;
import org.bluez.exceptions.BluezNotSupportedException;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.Variant;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> unique name (Target role)<br>
* <b>Interface:</b> org.bluez.MediaFolder1<br>
* <br>
* <b>Object path:</b><br>
* freely definable (Target role)<br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/playerX<br>
* (Controller role)
* <br>
* <b>Supported properties:</b> <br>
* <br>
* uint32 NumberOfItems [readonly]<br>
* <br>
* Number of items in the folder<br>
* <br>
* string Name [readonly]<br>
* <br>
* Folder name:<br>
* <br>
* Possible values:<br>
* "/Filesystem/...": Filesystem scope<br>
* "/NowPlaying/...": NowPlaying scope<br>
* <br>
* Note: /NowPlaying folder might not be listed if player<br>
* is stopped, folders created by Search are virtual so<br>
* once another Search is perform or the folder is<br>
* changed using ChangeFolder it will no longer be listed.<br>
* <br>
* <br>
* Offset of the first item.<br>
* <br>
* Default value: 0<br>
* <br>
* uint32 End:<br>
* <br>
* Offset of the last item.<br>
* <br>
* Default value: NumbeOfItems<br>
* <br>
* array{string} Attributes<br>
* <br>
* Item properties that should be included in the list.<br>
* <br>
* Possible Values:<br>
* <br>
* "title", "artist", "album", "genre",<br>
* "number-of-tracks", "number", "duration"<br>
* <br>
* Default Value: All<br>
* <br>
* <br>
*/
public interface MediaFolder1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a folder object containing the search result.<br>
* <br>
* To list the items found use the folder object returned<br>
* and pass to ChangeFolder.<br>
* <br>
*
* @param _value value
* @param _filter filter
*
* @return DBusPath - maybe null
*
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/
DBusPath Search(String _value, Map<String, Variant<?>> _filter) throws BluezNotSupportedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Return a list of items found<br>
* <br>
*
* @param _filter filter
*
* @return TwoTuple<DBusPath, Properties>[] - maybe null
*
* @throws BluezInvalidArgumentsException when argument is invalid
* @throws BluezNotSupportedException when operation not supported
* @throws BluezFailedException on failure
*/ | TwoTuple<DBusPath, Properties>[] ListItems(Map<String, Variant<?>> _filter) throws BluezInvalidArgumentsException, BluezNotSupportedException, BluezFailedException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/MediaTransport1.java | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java
// public class ThreeTuple<A, B, C> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
// @Position(2)
// private C thirdValue;
//
// public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// thirdValue = _thirdValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// public C getThirdValue() {
// return thirdValue;
// }
//
// public void setThirdValue(C _thirdValue) {
// thirdValue = _thirdValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java
// @SuppressWarnings("serial")
// public class BluezNotAuthorizedException extends DBusException {
//
// public BluezNotAuthorizedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAvailableException.java
// @SuppressWarnings("serial")
// public class BluezNotAvailableException extends DBusException {
//
// public BluezNotAvailableException(String _message) {
// super(_message);
// }
//
// }
| import org.bluez.datatypes.ThreeTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezNotAuthorizedException;
import org.bluez.exceptions.BluezNotAvailableException;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.UInt16; | package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.MediaTransport1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/fdX<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* object Device [readonly]<br>
* <br>
* Device object which the transport is connected to.<br>
* <br>
* string UUID [readonly]<br>
* <br>
* UUID of the profile which the transport is for.<br>
* <br>
* byte Codec [readonly]<br>
* <br>
* Assigned number of codec that the transport support.<br>
* The values should match the profile specification which<br>
* is indicated by the UUID.<br>
* <br>
* array{byte} Configuration [readonly]<br>
* <br>
* Configuration blob, it is used as it is so the size and<br>
* byte order must match.<br>
* <br>
* string State [readonly]<br>
* <br>
* Indicates the state of the transport. Possible<br>
* values are:<br>
* "idle": not streaming<br>
* "pending": streaming but not acquired<br>
* "active": streaming and acquired<br>
* <br>
* uint16 Delay [readwrite]<br>
* <br>
* Optional. Transport delay in 1/10 of millisecond, this<br>
* property is only writeable when the transport was<br>
* acquired by the sender.<br>
* <br>
* uint16 Volume [readwrite]<br>
* <br>
* Optional. Indicates volume level of the transport,<br>
* this property is only writeable when the transport was<br>
* acquired by the sender.<br>
* <br>
* Possible Values: 0-127<br>
* <br>
* object Endpoint [readonly, optional, experimental]<br>
* <br>
* Endpoint object which the transport is associated<br>
* with.<br>
* <br>
*/
public interface MediaTransport1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Acquire transport file descriptor and the MTU for read<br>
* and write respectively.<br>
* <br>
*
* @return ThreeTuple<FileDescriptor, UInt16, UInt16> - maybe null
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezFailedException on failure
*/
ThreeTuple<FileDescriptor, UInt16, UInt16> Acquire() throws BluezNotAuthorizedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Acquire transport file descriptor only if the transport<br>
* is in "pending" state at the time the message is<br>
* received by BlueZ. Otherwise no request will be sent<br>
* to the remote device and the function will just fail<br>
* with org.bluez.Error.NotAvailable.<br>
* <br>
*
* @return ThreeTuple<FileDescriptor, UInt16, UInt16> - maybe null
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezFailedException on failure
* @throws BluezNotAvailableException when not available
*/ | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/ThreeTuple.java
// public class ThreeTuple<A, B, C> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
// @Position(2)
// private C thirdValue;
//
// public ThreeTuple(A _firstValue, B _secondValue, C _thirdValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// thirdValue = _thirdValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// public C getThirdValue() {
// return thirdValue;
// }
//
// public void setThirdValue(C _thirdValue) {
// thirdValue = _thirdValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezFailedException.java
// @SuppressWarnings("serial")
// public class BluezFailedException extends DBusException {
//
// public BluezFailedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAuthorizedException.java
// @SuppressWarnings("serial")
// public class BluezNotAuthorizedException extends DBusException {
//
// public BluezNotAuthorizedException(String _message) {
// super(_message);
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/BluezNotAvailableException.java
// @SuppressWarnings("serial")
// public class BluezNotAvailableException extends DBusException {
//
// public BluezNotAvailableException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/MediaTransport1.java
import org.bluez.datatypes.ThreeTuple;
import org.bluez.exceptions.BluezFailedException;
import org.bluez.exceptions.BluezNotAuthorizedException;
import org.bluez.exceptions.BluezNotAvailableException;
import org.freedesktop.dbus.FileDescriptor;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.UInt16;
package org.bluez;
/**
* File generated - 2020-06-18.<br>
* Based on bluez Documentation: media-api.txt.<br>
* <br>
* <b>Service:</b> org.bluez<br>
* <b>Interface:</b> org.bluez.MediaTransport1<br>
* <br>
* <b>Object path:</b><br>
* [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/fdX<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* object Device [readonly]<br>
* <br>
* Device object which the transport is connected to.<br>
* <br>
* string UUID [readonly]<br>
* <br>
* UUID of the profile which the transport is for.<br>
* <br>
* byte Codec [readonly]<br>
* <br>
* Assigned number of codec that the transport support.<br>
* The values should match the profile specification which<br>
* is indicated by the UUID.<br>
* <br>
* array{byte} Configuration [readonly]<br>
* <br>
* Configuration blob, it is used as it is so the size and<br>
* byte order must match.<br>
* <br>
* string State [readonly]<br>
* <br>
* Indicates the state of the transport. Possible<br>
* values are:<br>
* "idle": not streaming<br>
* "pending": streaming but not acquired<br>
* "active": streaming and acquired<br>
* <br>
* uint16 Delay [readwrite]<br>
* <br>
* Optional. Transport delay in 1/10 of millisecond, this<br>
* property is only writeable when the transport was<br>
* acquired by the sender.<br>
* <br>
* uint16 Volume [readwrite]<br>
* <br>
* Optional. Indicates volume level of the transport,<br>
* this property is only writeable when the transport was<br>
* acquired by the sender.<br>
* <br>
* Possible Values: 0-127<br>
* <br>
* object Endpoint [readonly, optional, experimental]<br>
* <br>
* Endpoint object which the transport is associated<br>
* with.<br>
* <br>
*/
public interface MediaTransport1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* Acquire transport file descriptor and the MTU for read<br>
* and write respectively.<br>
* <br>
*
* @return ThreeTuple<FileDescriptor, UInt16, UInt16> - maybe null
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezFailedException on failure
*/
ThreeTuple<FileDescriptor, UInt16, UInt16> Acquire() throws BluezNotAuthorizedException, BluezFailedException;
/**
* <b>From bluez documentation:</b><br>
* <br>
* Acquire transport file descriptor only if the transport<br>
* is in "pending" state at the time the message is<br>
* received by BlueZ. Otherwise no request will be sent<br>
* to the remote device and the function will just fail<br>
* with org.bluez.Error.NotAvailable.<br>
* <br>
*
* @return ThreeTuple<FileDescriptor, UInt16, UInt16> - maybe null
*
* @throws BluezNotAuthorizedException when not authorized
* @throws BluezFailedException on failure
* @throws BluezNotAvailableException when not available
*/ | ThreeTuple<FileDescriptor, UInt16, UInt16> TryAcquire() throws BluezNotAuthorizedException, BluezFailedException, BluezNotAvailableException; |
hypfvieh/bluez-dbus | bluez-dbus/src/main/java/org/bluez/mesh/Provisioner1.java | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/mesh/BluezMeshAbortException.java
// @SuppressWarnings("serial")
// public class BluezMeshAbortException extends DBusException {
//
// public BluezMeshAbortException(String _message) {
// super(_message);
// }
//
// }
| import java.util.Map;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.mesh.BluezMeshAbortException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.UInt16;
import org.freedesktop.dbus.types.Variant; | package org.bluez.mesh;
/**
* File generated - 2020-12-28.<br>
* Based on bluez Documentation: mesh-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.mesh.Provisioner1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* An array of strings with the following allowed values:<br>
* "blink"<br>
* "beep"<br>
* "vibrate"<br>
* "out-numeric"<br>
* "out-alpha"<br>
* "push"<br>
* "twist"<br>
* "in-numeric"<br>
* "in-alpha"<br>
* "static-oob"<br>
* "public-oob"<br>
* <br>
* <br>
* Indicates availability of OOB data. An array of strings with the<br>
* following allowed values:<br>
* "other"<br>
* "uri"<br>
* "machine-code-2d"<br>
* "bar-code"<br>
* "nfc"<br>
* "number"<br>
* "string"<br>
* "on-box"<br>
* "in-box"<br>
* "on-paper",<br>
* "in-manual"<br>
* "on-device"<br>
* <br>
* <br>
* Uniform Resource Identifier points to out-of-band (OOB)<br>
* information (e.g., a public key)<br>
* <br>
* <br>
*/
public interface Provisioner1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* The method is called from the bluetooth-meshd daemon when a<br>
* unique UUID has been seen during UnprovisionedScan() for<br>
* unprovsioned devices.<br>
* <br>
* The rssi parameter is a signed, normalized measurement of the<br>
* signal strength of the recieved unprovisioned beacon.<br>
* <br>
* The data parameter is a variable length byte array, that may<br>
* have 1, 2 or 3 distinct fields contained in it including the 16<br>
* byte remote device UUID (always), a 16 bit mask of OOB<br>
* authentication flags (optional), and a 32 bit URI hash (if URI<br>
* bit set in OOB mask). Whether these fields exist or not is a<br>
* decision of the remote device.<br>
* <br>
* The options parameter is a dictionary that may contain<br>
* additional scan result info (currently an empty placeholder for<br>
* forward compatibility).<br>
* <br>
* If a beacon with a UUID that has already been reported is<br>
* recieved by the daemon, it will be silently discarded unless it<br>
* was recieved at a higher rssi power level.
*
* @param _rssi rssi
* @param _data data
* @param _options options
*/
void ScanResult(int _rssi, byte[] _data, Map<String, Variant<?>> _options);
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method is implemented by a Provisioner capable application<br>
* and is called when the remote device has been fully<br>
* authenticated and confirmed.<br>
* <br>
* The count parameter is the number of consecutive unicast<br>
* addresses the remote device is requesting.<br>
* <br>
* Return Parameters are from the Mesh Profile Spec:<br>
* net_index - Subnet index of the net_key<br>
* unicast - Primary Unicast address of the new node
*
* @param _count count
*
* @return Tuple of net_index and unicast, maybe null
*
* @throws BluezMeshAbortException when operation is aborted
*/ | // Path: bluez-dbus/src/main/java/org/bluez/datatypes/TwoTuple.java
// public class TwoTuple<A, B> extends Tuple {
//
// @Position(0)
// private A firstValue;
// @Position(1)
// private B secondValue;
//
// public TwoTuple(A _firstValue, B _secondValue) {
// firstValue = _firstValue;
// secondValue = _secondValue;
// }
//
// public A getFirstValue() {
// return firstValue;
// }
//
// public void setFirstValue(A _firstValue) {
// firstValue = _firstValue;
// }
//
// public B getSecondValue() {
// return secondValue;
// }
//
// public void setSecondValue(B _secondValue) {
// secondValue = _secondValue;
// }
//
// }
//
// Path: bluez-dbus/src/main/java/org/bluez/exceptions/mesh/BluezMeshAbortException.java
// @SuppressWarnings("serial")
// public class BluezMeshAbortException extends DBusException {
//
// public BluezMeshAbortException(String _message) {
// super(_message);
// }
//
// }
// Path: bluez-dbus/src/main/java/org/bluez/mesh/Provisioner1.java
import java.util.Map;
import org.bluez.datatypes.TwoTuple;
import org.bluez.exceptions.mesh.BluezMeshAbortException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.types.UInt16;
import org.freedesktop.dbus.types.Variant;
package org.bluez.mesh;
/**
* File generated - 2020-12-28.<br>
* Based on bluez Documentation: mesh-api.txt.<br>
* <br>
* <b>Service:</b> unique name<br>
* <b>Interface:</b> org.bluez.mesh.Provisioner1<br>
* <br>
* <b>Object path:</b><br>
* freely definable<br>
* <br>
* <b>Supported properties:</b> <br>
* <br>
* An array of strings with the following allowed values:<br>
* "blink"<br>
* "beep"<br>
* "vibrate"<br>
* "out-numeric"<br>
* "out-alpha"<br>
* "push"<br>
* "twist"<br>
* "in-numeric"<br>
* "in-alpha"<br>
* "static-oob"<br>
* "public-oob"<br>
* <br>
* <br>
* Indicates availability of OOB data. An array of strings with the<br>
* following allowed values:<br>
* "other"<br>
* "uri"<br>
* "machine-code-2d"<br>
* "bar-code"<br>
* "nfc"<br>
* "number"<br>
* "string"<br>
* "on-box"<br>
* "in-box"<br>
* "on-paper",<br>
* "in-manual"<br>
* "on-device"<br>
* <br>
* <br>
* Uniform Resource Identifier points to out-of-band (OOB)<br>
* information (e.g., a public key)<br>
* <br>
* <br>
*/
public interface Provisioner1 extends DBusInterface {
/**
* <b>From bluez documentation:</b><br>
* <br>
* The method is called from the bluetooth-meshd daemon when a<br>
* unique UUID has been seen during UnprovisionedScan() for<br>
* unprovsioned devices.<br>
* <br>
* The rssi parameter is a signed, normalized measurement of the<br>
* signal strength of the recieved unprovisioned beacon.<br>
* <br>
* The data parameter is a variable length byte array, that may<br>
* have 1, 2 or 3 distinct fields contained in it including the 16<br>
* byte remote device UUID (always), a 16 bit mask of OOB<br>
* authentication flags (optional), and a 32 bit URI hash (if URI<br>
* bit set in OOB mask). Whether these fields exist or not is a<br>
* decision of the remote device.<br>
* <br>
* The options parameter is a dictionary that may contain<br>
* additional scan result info (currently an empty placeholder for<br>
* forward compatibility).<br>
* <br>
* If a beacon with a UUID that has already been reported is<br>
* recieved by the daemon, it will be silently discarded unless it<br>
* was recieved at a higher rssi power level.
*
* @param _rssi rssi
* @param _data data
* @param _options options
*/
void ScanResult(int _rssi, byte[] _data, Map<String, Variant<?>> _options);
/**
* <b>From bluez documentation:</b><br>
* <br>
* This method is implemented by a Provisioner capable application<br>
* and is called when the remote device has been fully<br>
* authenticated and confirmed.<br>
* <br>
* The count parameter is the number of consecutive unicast<br>
* addresses the remote device is requesting.<br>
* <br>
* Return Parameters are from the Mesh Profile Spec:<br>
* net_index - Subnet index of the net_key<br>
* unicast - Primary Unicast address of the new node
*
* @param _count count
*
* @return Tuple of net_index and unicast, maybe null
*
* @throws BluezMeshAbortException when operation is aborted
*/ | TwoTuple<UInt16, UInt16> RequestProvData(byte _count) throws BluezMeshAbortException; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.