- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.spotify.helios.servicescommon.coordination.ZooKeeperUpdatingPersistentDirectory
类的一些代码示例,展示了ZooKeeperUpdatingPersistentDirectory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUpdatingPersistentDirectory
类的具体详情如下:
包路径:com.spotify.helios.servicescommon.coordination.ZooKeeperUpdatingPersistentDirectory
类名称:ZooKeeperUpdatingPersistentDirectory
[英]A map that persists modification locally on disk and attempt to replicate modifications to ZooKeeper, retrying forever until successful. Note that ZooKeeper is only written to and never read from, so this is not a distributed map. Multiple changes to the same key are folded and only the last value is written to ZooKeeper.
[中]在磁盘上本地保存修改并尝试将修改复制到ZooKeeper的映射,永远重试,直到成功。请注意,ZooKeeper只被写入,从不被读取,所以这不是一个分布式地图。对同一个键的多个更改被折叠,只有最后一个值被写入ZooKeeper。
代码示例来源:origin: spotify/helios
public static ZooKeeperUpdatingPersistentDirectory create(final String name,
final ZooKeeperClientProvider client,
final Path stateFile,
final String path)
throws IOException, InterruptedException {
return new ZooKeeperUpdatingPersistentDirectory(name, client, stateFile, path);
}
代码示例来源:origin: spotify/helios
/**
* Returns the {@link TaskStatus}es for all tasks assigned to the current agent.
*/
@Override
public Map<JobId, TaskStatus> getTaskStatuses() {
final Map<JobId, TaskStatus> statuses = Maps.newHashMap();
for (final Map.Entry<String, byte[]> entry : this.taskStatuses.entrySet()) {
try {
final JobId id = JobId.fromString(entry.getKey());
final TaskStatus status = Json.read(entry.getValue(), TaskStatus.class);
statuses.put(id, status);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return statuses;
}
代码示例来源:origin: spotify/helios
/**
* Get the {@link TaskStatus} for the job identified by {@code jobId}.
*/
@Override
public TaskStatus getTaskStatus(final JobId jobId) {
final byte[] data = taskStatuses.get(jobId.toString());
if (data == null) {
return null;
}
try {
return parse(data, TaskStatus.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: spotify/helios
public byte[] remove(final Object key) throws InterruptedException {
if (!(key instanceof String)) {
return null;
}
return remove((String) key);
}
代码示例来源:origin: spotify/helios
@Override
protected void startUp() throws Exception {
client("startUp").getConnectionStateListenable().addListener(connectionStateListener);
reactor.startAsync().awaitRunning();
reactor.signal();
}
代码示例来源:origin: spotify/helios
@Override
protected void shutDown() throws Exception {
tasks.stopAsync().awaitTerminated();
taskStatuses.stopAsync().awaitTerminated();
if (historyWriter != null) {
historyWriter.stopAsync().awaitTerminated();
}
}
代码示例来源:origin: spotify/helios
@Override
protected void startUp() throws Exception {
tasks.startAsync().awaitRunning();
taskStatuses.startAsync().awaitRunning();
if (historyWriter != null) {
historyWriter.startAsync().awaitRunning();
}
}
代码示例来源:origin: spotify/helios
private boolean isAlive() {
return state().ordinal() < STOPPING.ordinal();
}
代码示例来源:origin: spotify/helios
public ZooKeeperAgentModel(final ZooKeeperClientProvider provider,
final String host,
final Path stateDirectory,
final TaskHistoryWriter historyWriter,
final List<EventSender> eventSenders,
final String taskStatusEventTopic)
throws IOException, InterruptedException {
// TODO(drewc): we're constructing too many heavyweight things in the ctor, these kinds of
// things should be passed in/provider'd/etc.
final ZooKeeperClient client = provider.get("ZooKeeperAgentModel_ctor");
this.agent = checkNotNull(host);
final Path taskConfigFile = stateDirectory.resolve(TASK_CONFIG_FILENAME);
this.tasks = client.pathChildrenCache(Paths.configHostJobs(host), taskConfigFile,
Json.type(Task.class));
tasks.addListener(new JobsListener());
final Path taskStatusFile = stateDirectory.resolve(TASK_STATUS_FILENAME);
this.taskStatuses = ZooKeeperUpdatingPersistentDirectory.create("agent-model-task-statuses",
provider,
taskStatusFile,
Paths.statusHostJobs(host));
this.historyWriter = historyWriter;
this.eventSenders = eventSenders;
this.taskStatusEventTopic = taskStatusEventTopic;
}
代码示例来源:origin: spotify/helios
/**
* Set the {@link TaskStatus} for the job identified by {@code jobId}.
*/
@Override
public void setTaskStatus(final JobId jobId, final TaskStatus status)
throws InterruptedException {
log.debug("setting task status: {}", status);
taskStatuses.put(jobId.toString(), status.toJsonBytes());
if (historyWriter != null) {
try {
historyWriter.saveHistoryItem(status);
} catch (Exception e) {
// Log error here and keep going as saving task history is not critical.
// This is to prevent bad data in the queue from screwing up the actually important Helios
// agent operations.
log.error("Error saving task status {} to ZooKeeper: {}", status, e);
}
}
final TaskStatusEvent event = new TaskStatusEvent(status, System.currentTimeMillis(), agent);
final byte[] message = event.toJsonBytes();
for (final EventSender sender : eventSenders) {
sender.send(taskStatusEventTopic, message);
}
}
代码示例来源:origin: spotify/helios
/**
* Remove the {@link TaskStatus} for the job identified by {@code jobId}.
*/
@Override
public void removeTaskStatus(final JobId jobId) throws InterruptedException {
taskStatuses.remove(jobId.toString());
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void startUp() throws Exception {
client("startUp").getConnectionStateListenable().addListener(connectionStateListener);
reactor.startAsync().awaitRunning();
reactor.signal();
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void shutDown() throws Exception {
tasks.stopAsync().awaitTerminated();
taskStatuses.stopAsync().awaitTerminated();
historyWriter.stopAsync().awaitTerminated();
}
代码示例来源:origin: at.molindo/helios-services
@Override
protected void startUp() throws Exception {
tasks.startAsync().awaitRunning();
taskStatuses.startAsync().awaitRunning();
historyWriter.startAsync().awaitRunning();
}
代码示例来源:origin: at.molindo/helios-services
private boolean isAlive() {
return state().ordinal() < STOPPING.ordinal();
}
代码示例来源:origin: at.molindo/helios-services
public ZooKeeperAgentModel(final ZooKeeperClientProvider provider,
final KafkaClientProvider kafkaProvider, final String host,
final Path stateDirectory) throws IOException, InterruptedException {
// TODO(drewc): we're constructing too many heavyweight things in the ctor, these kinds of
// things should be passed in/provider'd/etc.
final ZooKeeperClient client = provider.get("ZooKeeperAgentModel_ctor");
this.agent = checkNotNull(host);
final Path taskConfigFile = stateDirectory.resolve(TASK_CONFIG_FILENAME);
this.tasks = client.pathChildrenCache(Paths.configHostJobs(host), taskConfigFile,
Json.type(Task.class));
tasks.addListener(new JobsListener());
final Path taskStatusFile = stateDirectory.resolve(TASK_STATUS_FILENAME);
this.taskStatuses = ZooKeeperUpdatingPersistentDirectory.create("agent-model-task-statuses",
provider,
taskStatusFile,
Paths.statusHostJobs(host));
this.historyWriter = new TaskHistoryWriter(
host, client, stateDirectory.resolve(TASK_HISTORY_FILENAME));
this.kafkaSender = new KafkaSender(
kafkaProvider.getProducer(new StringSerializer(), new ByteArraySerializer()));
}
代码示例来源:origin: at.molindo/helios-services
/**
* Set the {@link TaskStatus} for the job identified by {@code jobId}.
*/
@Override
public void setTaskStatus(final JobId jobId, final TaskStatus status)
throws InterruptedException {
log.debug("setting task status: {}", status);
taskStatuses.put(jobId.toString(), status.toJsonBytes());
try {
historyWriter.saveHistoryItem(status);
} catch (Exception e) {
// Log error here and keep going as saving task history is not critical.
// This is to prevent bad data in the queue from screwing up the actually important Helios
// agent operations.
log.error("Error saving task status {} to ZooKeeper: {}", status, e);
}
final TaskStatusEvent event = new TaskStatusEvent(status, System.currentTimeMillis(), agent);
kafkaSender.send(KafkaRecord.of(TaskStatusEvent.KAFKA_TOPIC, event.toJsonBytes()));
}
代码示例来源:origin: at.molindo/helios-services
public byte[] remove(final Object key) throws InterruptedException {
if (!(key instanceof String)) {
return null;
}
return remove((String) key);
}
代码示例来源:origin: at.molindo/helios-services
public static ZooKeeperUpdatingPersistentDirectory create(final String name,
final ZooKeeperClientProvider client,
final Path stateFile,
final String path)
throws IOException, InterruptedException {
return new ZooKeeperUpdatingPersistentDirectory(name, client, stateFile, path);
}
代码示例来源:origin: at.molindo/helios-services
/**
* Get the {@link TaskStatus} for the job identified by {@code jobId}.
*/
@Override
public TaskStatus getTaskStatus(final JobId jobId) {
final byte[] data = taskStatuses.get(jobId.toString());
if (data == null) {
return null;
}
try {
return parse(data, TaskStatus.class);
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
据我所知,不可能开发一个Web应用程序(在spotify.com之外)提供播放Spotify歌曲的自定义Web播放器,对吗?唯一的选择似乎仍然是 Spotify 播放按钮,但功能非常有限。 不过,我刚
我想从 Spotify 应用程序中运行 Spotify 搜索(以查找艺术家的轨道,我没有该艺术家的 Spotify URI,只有名称)。 我尚未在 App API 中找到用于运行搜索的功能。另一种方法
所以我看了一下spotify web api,它显然允许你播放歌曲的预览,但我想知道是否有任何方法可以播放完整的spotify歌曲而无需打开官方的spotify网络播放器或桌面应用程序。 谢谢 最佳答
我在使用 Spotify API 时发现了一个奇怪的行为。有些轨道有两个不同的 ID,即使轨道在同一张专辑中也是如此。 例子: https://api.spotify.com/v1/tracks/0Y
我只想能够通过发送/接收 http 请求(一个独立的网络应用程序,而不是 Spotify 应用程序和桌面客户端)来创建一个播放列表。我翻遍了文档,找不到明确的解决方案。有人可以指出我正确的方向吗?提前
如何将轨道添加到 Spotify 应用程序中的当前播放队列? 最佳答案 您需要创建一个未命名的播放列表来创建您自己的播放队列。 function playTracks(tracks, index) {
有没有像 Spotify 远程控制 API 这样的东西?我想编写一个应用程序,让用户控制 Spotify 桌面客户端(播放、暂停、音量、播放列表等),但我似乎无法在任何地方找到任何文档。 那里有 iO
在 Google 上找不到关于该主题的任何内容,所以我在这里问。 我有一个基于网络的 Spotify 播放器(不像官方播放器)的想法,我想知道是否可以让客户端(用户)从 Spotify 而不是我的服务
我是 playmoss 的开发人员,用户可以在其中创建具有不同音乐服务的播放列表。 我们计划以类似于 bop.fm 的方式将 Spotify 支持添加到我们的播放列表中。 语境 以这个播放列表为例(其
我正在尝试创建一个 Spotify 应用程序,但在登录时收到一条奇怪的错误消息:*19:28:57.916 I [offline_authorizer.cpp:289]无法离线登录:没有这样的用户 i
我正在尝试开发一个应用程序,在该应用程序中我需要解决一个查询,以按城市位置获取艺术家的追随者和听众的数量。 提前致谢, 笔记: 我已经检查过可以通过使用搜索方法 spotify.search(q="A
我使用 Spotify 来满足我所有的音乐需求,并且想知道是否有某种方法可以编写一个应用程序,让我可以从 Spotify 访问音乐并放慢歌曲速度并循环播放部分歌曲。我是一名音乐家,像这样的东西会有助于
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 6 年前。 Improve this qu
如何使用 Spotify API 在 Spotify 上获得“全局”热门轨道列表?例如,我的意思是现在 Spotify 上最流行的 20 首歌曲的列表(对于任何艺术家/国家/地区) 我已经在谷歌上搜索
我在 Raspberry Pi 上使用 libspotify 12.1.103.gd51f6226 Release Linux-armv6-bcm2708hardfp,我认为按照自述文件中的说明一切正
我正在尝试获取有关 Spotify iOS 应用程序中当前正在播放的歌曲的信息。场景如下:打开Spotify iOS应用程序,开始播放歌曲。将应用程序置于后台并打开我的 iOS 应用程序。有什么办法可
请告知如何在使用 Spotify Web API“https://accounts.spotify.com/api/token”获取数据时增加 token 到期时间 最佳答案 访问 token 在一小
是否可以获得歌曲的播放次数(对于当前用户)?我只找到Toplist和 Track类,但都没有告诉我用户听歌曲的频率。 最佳答案 据我所知,目前无法检索该数据。 关于spotify - 从 Spotif
我想使用 spotify api 来创建一个 webapp。在不详细介绍该项目的情况下,我想弄清楚它是否违反条款和条件。 阅读条款和条件后,我在“不要做的事情”下阅读了这一行:“聚合元数据以创建数据库
在浏览了今天发布的 Spotify Web API 文档后,似乎没有办法播放完整长度的歌曲,即使在授权之后也是如此。 API 似乎只支持 30 秒的歌曲预览。 是否有用于 javascript 的 S
我是一名优秀的程序员,十分优秀!