小编Chr*_*man的帖子

使用S3,CloudFront和Origin Path进行静态网站托管的子文件夹重定向问题

我在使用Amazon S3和Cloudfront设置静态网站托管时遇到了一些困难.

我们有许多网站可以作为使用Amazon S3 + Cloudfront的静态网站提供服务,我们希望将它们全部托管在一个S3存储桶中.

初始设置非常简单但如果省略URL中的尾部斜杠,我们就会遇到子文件夹重定向问题.

例如,从存储桶中设置单个网站:

网站1的存储桶内容:

S3://bucket-name/websites/website1/index.html

S3://bucket-name/websites/website1/about/index.html

我为此存储桶启用了静态网站托管,默认文档设置为"index.html"

我创建了一个Cloudfront Web分发来为这个单一网站提供服务,默认根对象设置为'index.html'.

该发行版有一个自定义来源,指向静态网站网址"bucket-name.s3-website-us-east-1.amazonaws.com",其中Origin Path设置为'/ websites/website1'

导航到分发网址" http://example.cloudfront.net "时,它会正确地提供"s3://bucket-name/websites/website1/index.html"中的"index.html"文档

当导航到" http://example.cloudfront.net/about/ "这也正常供应来自"的index.html"文件"S3://bucket-name/websites/website1/about/index.html"

但是,如果我忽略像"结尾的斜线http://example.cloudfront.net/about " S3重定向我" http://example.cloudfront.net/websites/website1/about/ ",因为我有产地路径设置为'/ websites/website1'Cloudfront将从不存在的's3://bucket-name/websites/website1/about/websites/website1/about/index.html'请求index.html.

我在这里错过了什么吗?仅使用Cloudfront和S3这是不可能的设置吗?

amazon-s3 amazon-cloudfront

8
推荐指数
1
解决办法
8010
查看次数

随着索引和文档数量的不断增加,elasticsearch批量索引会逐渐变慢

我遇到使用.NET NEST客户端和ElasticSearch的批量索引性能会随着时间的推移而降级,并且会有一定数量的索引和文档数量.

我们ElasticSearch Version: 0.19.11, JVM: 23.5-b02使用Ubuntu Server 12.04.1 LTS 64位和Sun Java 7在m1.large Amazon实例上运行.除了Ubuntu安装附带的内容之外,此实例上没有其他任何东西在运行.

Amazon M1大型实例:来自http://aws.amazon.com/ec2/instance-types/

7.5 GiB memory
4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each)
850 GB instance storage
64-bit platform
I/O Performance: High
EBS-Optimized Available: 500 Mbps
API name: m1.large
Run Code Online (Sandbox Code Playgroud)

ES_MAX_MEM设置为4g,ES_MIN_MEM设置为2g

每天晚上我们在.NET应用程序中使用NEST索引/重新索引~15000个文档.在任何给定时间,只有一个索引<= 15000个文档.

当服务器第一次安装时,索引和搜索在前几天很快,然后索引开始变得越来越慢.批量索引一次索引100个文档,一段时间后,批量操作完成需要15秒.之后我们开始看到很多以下异常并且索引磨削停止.

System.Net.WebException: The request was aborted: The request was canceled.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) : …
Run Code Online (Sandbox Code Playgroud)

.net lucene amazon-ec2 elasticsearch nest

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

如何将泛型类型传递给Argonaut

我试图包装Argonaut(http://argonaut.io),以便在Scala项目中序列化/反序列化JSON.我们之前使用过Jerkson但是因为它已经停产,我们正在寻找替代方案.

这是基本的JSON包装器

import argonaut._, Argonaut._

object Json {
  def Parse[T](input: String): T = {
    input.decodeOption[T].get
  }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译它时,我得到以下错误.

could not find implicit value for evidence parameter of type argonaut.DecodeJson[T]
    input.decodeOption[T]
                  ^
not enough arguments for method decodeOption: (implicit evidence$6: argonaut.DecodeJson[T]) Option[T].
Unspecified value parameter evidence$6.
    input.decodeOption[T]
                  ^
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题的建议或关于我做错的指示将是非常感激的.

关于替代JSON框架的建议也非常受欢迎.

我是Scala/Java的新手,以及泛型如何在那里工作但我多年来一直在编写.NET/C#.

scala jerkson

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

如何使用json4s将JString转换为Int

我们最近从Jerkson切换到json4s,我们很快发现这两个库的默认反序列化行为远非相同.

我们遇到的一个问题是我们有时会收到json输入,其中数字字段表示为字符串而不是数字

//example json object with string representation of "id"
{
    "id" : "12545"
}


//example json object with number representation of "id"
{
    "id" : 12345
}
Run Code Online (Sandbox Code Playgroud)

这些需要反序列化到下面的类中

case class example(id:Int)
Run Code Online (Sandbox Code Playgroud)

这是我们将json反序列化为任意类的一般设置

import org.json4s.native.Serialization._
import org.json4s._
import org.json4s.native.JsonMethods._

object Json {
    implicit val formats = DefaultFormats
    def parse[T](json:String)(implicit mf: Manifest[T]):T =  {
        org.json4s.native.JsonMethods.parse(input).extract[T]
    }
}
Run Code Online (Sandbox Code Playgroud)

但每当我们尝试使用id的字符串表示形式解析json对象时,它会抛出异常并带有消息:

没有可用的优惠价值没有id的可用值不知道如何将JString(12545)转换为int

我一直在寻找一种为Integer字段设置自定义阅读器的方法,它试图将字符串解析为整数,但我还没有找到涵盖我们用例的解决方案.我们需要的是一般的捕获所有解决方案,以支持遗留应用程序.

谁知道如何实现这一目标?

json scala json4s

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

c#/ asp.net - 如何捕获"System.Web.HttpException:Request timed out"?

在我的asp.net/c#项目中,我使用iTextsharp dll从许多pdf文档中读取文本,但有时我会收到此错误

System.Web.HttpException:请求超时.

但是这样做的代码是:

    public static bool does_pdf_have_keyword(string keyword, string pdf_src) 
    {
        try
        {
            PdfReader pdfReader = new PdfReader(pdf_src);
            string currentText;
            int count = pdfReader.NumberOfPages;
            for (int page = 1; page <= count; page++)
            {
                ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
                currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
                if (currentText.IndexOf(keyword, StringComparison.OrdinalIgnoreCase) != -1) return true;
            }
            pdfReader.Close();
            return false;
        }
        catch
        {
            return false;
        }
    }
Run Code Online (Sandbox Code Playgroud)

那么为什么页面在try catch中遇到未处理的异常并且catch应该捕获所有内容?

c# asp.net httprequest itextsharp

2
推荐指数
1
解决办法
7205
查看次数