标签: snapshot

创建支持“快照”的 ConcurrentHashMap

我正在尝试创建一个ConcurrentHashMap支持“快照”的迭代器,以提供一致的迭代器,并且想知道是否有更有效的方法来做到这一点。问题是,如果同时创建两个迭代器,那么它们需要读取相同的值,而并发哈希映射的弱一致迭代器的定义并不能保证这种情况。如果可能的话,我还想避免锁定:地图中有数千个值,处理每个项目需要几十毫秒,并且我不想在这段时间内阻止写入者,因为这可能会导致写入者阻塞一分钟或更长时间。

到目前为止我所拥有的:

  1. ConcurrentHashMap's是字符串,其值是实例ConcurrentSkipListMap<Long, T>
  2. 当使用 向哈希表添加元素时putIfAbsent,会分配一个新的跳表,并通过 来添加该对象skipList.put(System.nanoTime(), t)
  3. 为了查询地图,我使用map.get(key).lastEntry().getValue()返回最新值。要查询快照(例如使用迭代器),我使用map.get(key).lowerEntry(iteratorTimestamp).getValue(),其中是初始化迭代器时调用iteratorTimestamp的结果。System.nanoTime()
  4. 如果删除一个对象,我使用map.get(key).put(timestamp, SnapShotMap.DELETED),其中 DELETED 是静态最终对象。

问题:

  1. 有没有一个库已经实现了这个?或者除此之外,是否有一种数据结构比 和 更ConcurrentHashMap合适ConcurrentSkipListMap更合适?我的键是可比较的,因此也许某种并发树比并发哈希表更好地支持快照。
  2. 我该如何防止这个东西继续增长?在 X 上或之前初始化的所有迭代器完成后,我可以删除键小于 X 的所有跳过列表条目(映射中的最后一个键除外),但我不知道有什么好方法来确定何时已经发生了这种情况:当迭代器的方法返回 false 时,我可以标记该迭代器已完成hasNext,但并非所有迭代器都一定会运行完成;我可以将 a 保留WeakReference为迭代器,以便可以检测它何时被垃圾收集,但除了使用一个迭代弱引用集合然后休眠数次的线程之外,我想不出一个好的方法来检测它。分钟 - 理想情况下,线程会阻塞WeakReference,并在包装​​的引用被 GC 时收到通知,但我不认为这是一个选项。

    ConcurrentSkipListMap<Long, WeakReference<Iterator>> iteratorMap;
    while(true) {
        long latestGC = 0;
        for(Map.Entry<Long, WeakReference<Iterator>> entry : iteratorMap.entrySet()) {
            if(entry.getValue().get() == null) {
                iteratorMap.remove(entry.getKey());
                latestGC = …
    Run Code Online (Sandbox Code Playgroud)

java algorithm multithreading snapshot data-structures

4
推荐指数
1
解决办法
4565
查看次数

将快照工件上传到 Nexus Repository Manager

默认情况下,第 3 方存储库由 Nexus 生成。我可以将发布工件部署到第3方,但它不支持上传快照。 发布存储库

我创建了另一个托管存储库“tecentRepository”来支持快照,但快照不再有“Artifact Upload”选项卡。

快照存储库

如何手动上传具有快照支持的工件?

upload snapshot nexus

4
推荐指数
1
解决办法
1万
查看次数

如果cassandra.yaml中启用了auto_snapshot,那么这些快照何时会被删除

如果我们在 cassandra.yaml 中设置auto_snapshot: true,并且删除一些表,那么将会创建该特定表的快照,对吗?那么这些快照什么时候会被删除呢?我们需要通过运行脚本手动删除它们吗?或者是否有一个设置可以让我在一段时间后自动删除它?

snapshot cassandra datastax-enterprise datastax cassandra-2.1

4
推荐指数
1
解决办法
3573
查看次数

路由器快照不起作用

这与“enzyme-to-snapshot-render-object-as-json”不同,因为

在这里,我想使用对象的JSON 定义
生成快照 ,另一个我想仅为组件生成的 HTML 生成快照。


快照测试总是失败,因为属性每次都key在变化。history

// ComponentContainer.jsx
class ComponentContainer extends Component {
  render() { ... }
}
export { ComponentContainer };    
export default withRouter(ComponentContainer);
Run Code Online (Sandbox Code Playgroud)

还有测试..

// ComponentContainer.test.jsx
import { ComponentContainer } from './ComponentContainer';

const minProps = {
  history: {
    push: jest.fn(),
  },
};

const wrapped = mount(
  <Router history={minProps.history}>
    <ComponentContainer.wrappedComponent {...mergedProps} {...mergedStores} />
  </Router>,
);

expect(toJson(wrapper)).toMatchSnapshot();
Run Code Online (Sandbox Code Playgroud)

生成此快照..

// ComponentContainer.test.jsx.snap
<MemoryRouter
    history={
      Object {
        "push": [Function],
      }
    }
  >
    <Router
      history={ …
Run Code Online (Sandbox Code Playgroud)

snapshot history.js jestjs react-router-v4

4
推荐指数
1
解决办法
1948
查看次数

即使在增量编译中,SBT 1.3.8 也会自动更新 SNAPSHOT 版本

从 SBT 1.3.0 开始,Coursier 是默认解析器引擎,因此我们从依赖项中删除了 Coursier SBT 插件。

在 Coursier-plugin 时代,我们曾经COURSIER_TTL="5 min"控制过SNAPSHOT自动获取版本的频率,甚至sbt ~test:compile在开发过程中何时使用。

对于依赖SNAPSHOT项目,这里是输出:

sbt:hub> show isSnapshot
[info] common / isSnapshot
[info]  true
[info] isSnapshot
[info]  true
Run Code Online (Sandbox Code Playgroud)
sbt:hub> show packagedArtifacts
[info] Wrote C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SN
APSHOT.pom
[info] Wrote C:\Users\Ehnalis\Projects\hub\target\scala-2.12\hub_2.12-0.5.0-SNAPSHOT.pom

[info] common / packagedArtifacts
[info]  Map(Artifact(common, jar, jar, None, Vector(compile), None, Map(), None, false)
-> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SNAPSHOT.jar
, Artifact(common, src, jar, Some(tests-sources), Vector(test), None, Map(), None, false
) -> C:\Users\Ehnalis\Projects\hub\common\target\scala-2.12\common_2.12-0.5.0-SNAPSHOT-t
ests-sources.jar, Artifact(common, jar, jar, Some(tests), Vector(test), …
Run Code Online (Sandbox Code Playgroud)

versioning scala compilation snapshot sbt

4
推荐指数
1
解决办法
508
查看次数

在 DBT 快照中遇到未知标签“快照”

我想运行 DBT 快照,并遵循与文档中概述的模板几乎相同的模板。但是,当我运行时出现错误dbt snpashot

Compilation Error in model test_snapshot (.../project_folder/snapshots/test_snapshot.sql)    
Encountered unknown tag 'snapshot'.
        line 1
          {% snapshot test_snapshot %}
Run Code Online (Sandbox Code Playgroud)

下面是我尝试编译的代码。

{% snapshot test_snapshot %}
    {{
        config(
            strategy='check',
            unique_key='id',
            target_schema='snapshots',
            check_cols= 'all'
        )
    }}

select
        *
from {{ ref('modle_in_sample_folder') }}

{% endsnapshot %}
Run Code Online (Sandbox Code Playgroud)

快照文件夹和参考文件的顺序是 .../project_folder/snapshots/test_snapshot.sql 和 .../project_folder/intermediate/model_in_sample_folder.sql

snapshot dbt

4
推荐指数
1
解决办法
2506
查看次数

如何创建系统还原点?

替代文字

安装paint.net,我找到一个字符串创建系统还原点...
我想它正在为卷影服务创建一个还原点. - 不是吗?我不确定.

如果我是对的,我该如何在我的应用程序中执行此操作?
如果有合适的Apis,请告诉我.

windows winapi snapshot volume-shadow-service

3
推荐指数
1
解决办法
1305
查看次数

ESXi 5.1每天或每晚都恢复为快照

我正在尝试将虚拟机每天或晚上恢复到以前的快照.不幸的是,我没有找到任何方法以我想要的方式这样做.

以下是我尝试过但不适合的一些事情:

- snapshot.action=autoRevert --> The VM has to HALT, REBOOT doesn't work the same. I don't want to power on my VM manually.

- snapshot.action=autoRevert on a running snapshot. I tried this, thinking it might work and resolve the first issue. But when i HALT my VM, the snapshot is reverted but the VM is placed in a suspended state...

- PowerCLI script : I don't want to have a Windows machine running just for this little thing.

- …
Run Code Online (Sandbox Code Playgroud)

automation snapshot esxi revert

3
推荐指数
1
解决办法
7759
查看次数

ServiceStack - 关闭快照

我在这里遵循了如何创建ServiceStack的说明:

https://github.com/ServiceStack/ServiceStack/wiki/Create-your-first-webservice

我确信我已经跟着它去了,但是一旦我运行Web应用程序.我得到了一个关于我的回复的"快照"视图.我知道当我没有默认视图/网页时会发生这种情况.我将项目设置为ASP.net网站,而不是ASP.net MVC网站.这可能是问题吗?

快照

我还用以下C#代码编写了一个测试控制台应用程序.它将响应作为HTML网页而不是简单的字符串,例如"Hello,John".

static void sendHello()
        {
            string contents = "john";
            string url = "http://localhost:51450/hello/";

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = contents.Length;
            request.ContentType = "application/x-www-form-urlencoded";

            // SEND TO WEBSERVICE
            using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
            {
                writer.Write(contents);
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            string result = string.Empty;

            using (StreamReader reader = new StreamReader(response.GetResponseStream()))
            {
                result = reader.ReadToEnd();
            }

            Console.WriteLine(result);
        }
Run Code Online (Sandbox Code Playgroud)

如何关闭"快照"视图?我究竟做错了什么?

snapshot servicestack

3
推荐指数
1
解决办法
1097
查看次数

Android Emulator Snapshot文件位置

我想知道Android模拟器快照在光盘上的存储位置。我知道如何通过扩展控制将它们带走,但是在光盘上找不到它们。我进行了文件系统搜索,但未找到任何结果。想法是与我的团队分享。

android snapshot adb

3
推荐指数
3
解决办法
2494
查看次数