小编tyr*_*ron的帖子

目标组没有关联的负载均衡器

我想从云形成脚本创建ECS服务。该服务需要通过Application Load Balancer暴露给外部

我创建了Elastic Load Balancer,一个Listener和ListnerRule

 Resources:
  Vpc:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsSupport: 'true'
      EnableDnsHostnames: 'true'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 0e3933ae-23c2-44e1-a0d9-82fcfba93511
  PubSubnetAz1:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Vpc
      CidrBlock: 10.0.1.0/24
      AvailabilityZone: 'ap-southeast-1a'
      MapPublicIpOnLaunch: true
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 6c7ca021-4114-4ec8-acf8-4f103ff7011f
  PubSubnetAz2:
    Type: 'AWS::EC2::Subnet'
    Properties:
      VpcId: !Ref Vpc
      CidrBlock: 10.0.2.0/24
      AvailabilityZone: 'ap-southeast-1b'
      MapPublicIpOnLaunch: true
    Metadata:
      'AWS::CloudFormation::Designer':
        id: cfe07e5c-e00f-4918-b877-f567fa08c802
  InternetGateway:
    Type: 'AWS::EC2::InternetGateway'
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 46bddd21-3027-4ccb-9e5d-ebf887429453
  AttachGateway:
    Type: 'AWS::EC2::VPCGatewayAttachment'
    Properties:
      VpcId: !Ref Vpc
      InternetGatewayId: !Ref InternetGateway
    Metadata:
      'AWS::CloudFormation::Designer':
        id: 11b7e802-d5ba-437a-8695-4bd5406d4db7
  RouteViaIgw:
    Type: 'AWS::EC2::RouteTable'
    Properties: …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-cloudformation

10
推荐指数
2
解决办法
2614
查看次数

实体框架 - 渴望加载相关实体

对不起,标题不是更具体 - 我不知道如何简洁地描述.我有Trips和Location,它们具有多对多的关系 - 直截了当,除了Locations不需要知道使用它们的Trips.我创建了这些实体来代表这个:

public class Trip
{
    public int TripId { get; set; }
    public virtual IList<TripLocation> TripLocations { get; set; }
}

public class TripLocation
{
    public int TripId { get; set; }
    public int LocationId { get; set; }

    public virtual Location Location { get; set; }
}

public class Location
{
    public int LocationId { get; set; }
    // Note: Intentionally no collection of Trips
}
Run Code Online (Sandbox Code Playgroud)

我可以让Trip快速加载它的TripLocations但我无法让TripLocations急于加载他们的位置.我已经尝试了一些流畅的配置组合和"包含"在查询中,如

IQueryable<Trip> query = from trip in context
                              .Include(r …
Run Code Online (Sandbox Code Playgroud)

entity-framework eager-loading ef-code-first

9
推荐指数
1
解决办法
6671
查看次数

在c#中使用Regex在字符串上拆分标记

我有一些"标记化"模板,例如(我称之为双括号之间的标记):

var template1 = "{{TOKEN1}} is a {{TOKEN2}} and it has some {{TOKEN3}}";
Run Code Online (Sandbox Code Playgroud)

我想从这句话中提取一个数组,以便有类似的东西:

Array("{{TOKEN1}}",
      " is a ",
      "{{TOKEN2}}", 
      " and it has some ", 
      "{{TOKEN3}}");
Run Code Online (Sandbox Code Playgroud)

我已尝试使用以下Regex代码实现此目的:

Regex r = new Regex(@"({{[^\}]*}})");
var n = r.Split(template1);
Run Code Online (Sandbox Code Playgroud)

结果是:

Array("",
      "{{TOKEN1}}",
      " is a ",
      "{{TOKEN2}}", 
      " and it has some ", 
      "{{TOKEN3}}",
      "");
Run Code Online (Sandbox Code Playgroud)

第一个问题是我无法从句子中恢复令牌.我只是通过在Regex表达式上添加括号来解决这个问题,即使我不确定为什么它会解决这个问题.

我目前面临的问题是当模板上的第一个和/或最后一个术语是"标记"时,数组开头和/或结尾的额外空术语.为什么会这样?我做错了什么,或者我应该经常检查这两个位置是否空虚?

在我的代码中,我需要知道哪个术语来自一个令牌,哪个是模板上的固定位置.在这个解决方案中,我将检查每个数组的位置,以"{{"和"}}"开头的字符串,我不认为这是最好的可能性.所以,如果有人想出一个更好的解决方案来打破这些事情,我会很高兴知道!

谢谢!

编辑:根据要求,我将发布一个简单的例子,为什么我需要对令牌和文本进行区分.

public abstract class TextParts { }
public class TextToken : TextParts { }
public class TextConstant : …
Run Code Online (Sandbox Code Playgroud)

c# regex split tokenize

9
推荐指数
1
解决办法
2143
查看次数

带包含的Linq查询仅适用于IQueryable是在外部变量中

我正在使用实体框架与Linq to Entities,尝试从我的数据库中选择一些数据.当我创建使用该方法的Linq查询时,IQueryable<int>.Contains如果我使用外部变量,它只能过滤数据!让我举一些例子.

这段代码完美无缺:

var volumes = (from v in work.VolumeAdditiveRepository.All
             where v.AdditivesID == AdditivesID
             select v.MetricID);
var metrics =
    from m in work.MetricRepository.All
    where !volumes.Contains(m.ID)
    select m;
Run Code Online (Sandbox Code Playgroud)

如果您仔细观察,您可以看到我volumes在此片段中使用变量where.如果我复制此变量的内容并将其粘贴到metrics变量中,导致下面的代码,则会引发错误:"Unable to create a constant value of type 'CalculadoraRFS.Models.Domain.VolumeAditivo'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.".

var metrics =
    from m in work.MetricRepository.All
    where !(from v in work.VolumeAdditiveRepository.All
             where v.AdditivesID == AdditivesID
             select …
Run Code Online (Sandbox Code Playgroud)

c# asp.net linq-to-entities entity-framework iqueryable

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

SlidingWindows用于Apache Beam上的慢速数据(大间隔)

我正在使用Chicago Traffic Tracker数据集,每15分钟发布一次新数据.当新数据可用时,它表示距离"实时"10-15分钟的记录(例如,查找_last_updt).

例如,在00:20,我得到数据时间戳00:10; 在00:35,我从00:20开始; 在00:50,我从00:40开始.因此,我可以获得新数据"固定"(每15分钟)的时间间隔,尽管时间戳上的间隔略有变化.

我试图在Dataflow(Apache Beam)上使用这些数据,为此我正在使用Sliding Windows.我的想法是收集和处理4个连续的数据点(4 x 15min = 60min),并且一旦新的数据点可用,理想情况下更新我的和/平均值的计算.为此,我开始使用代码:

PCollection<TrafficData> trafficData = input        
    .apply("MapIntoSlidingWindows", Window.<TrafficData>into(
        SlidingWindows.of(Duration.standardMinutes(60)) // (4x15)
            .every(Duration.standardMinutes(15))) .     // interval to get new data
        .triggering(AfterWatermark
                        .pastEndOfWindow()
                        .withEarlyFirings(AfterProcessingTime.pastFirstElementInPane()))
        .withAllowedLateness(Duration.ZERO)
        .accumulatingFiredPanes());
Run Code Online (Sandbox Code Playgroud)

不幸的是,看起来当我从输入中收到一个新的数据点时,我没有得到一个新的(更新的)结果GroupByKey.

我的SlidingWindows有问题吗?还是我错过了别的什么?

java sliding-window google-cloud-dataflow apache-beam

6
推荐指数
1
解决办法
503
查看次数

如何获取当前滑动窗口的最大时间戳

我正在使用 X 大小和 Y 周期的滑动时间窗口。为了标记每个窗口的输出,我想获取PCollection当前窗口的时间戳。

    PCollection<T> windowedInput = input
      .apply(Window<T>into(
          SlidingWindows.of(Duration.standardMinutes(10))
                        .every(Duration.standardMinutes(1))));

   // Extract key from each input and run a function per group.
   //
   // Q: ExtractKey() depends on the window triggered time.
   //    How can I pass the timestamp of windowedInputs to ExtractKey()?
   PCollection<KV<K, Iterable<T>>> groupedInputs = windowedInputs
     .apply(ParDo.of(new ExtractKey()))
     .apply(GroupByKey.<K, Ts>create());

   // Run Story clustering and write outputs.
   //
   // Q: Also I'd like to add a window timestamp suffix to the output.
   //    How can I …
Run Code Online (Sandbox Code Playgroud)

google-cloud-dataflow

0
推荐指数
1
解决办法
742
查看次数